2 .\" Copyright (c) 2017 Martin Pieuchot
3 .\" Copyright (c) 2018, 2019 Stefan Sperling
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 is a version control system which stores the history of tracked files
31 in a Git repository, as used by the Git version control system.
32 This repository format is described in
33 .Xr git-repository 5 .
38 version control system because every copy of a repository is writeable.
39 Modifications made to files can be synchronized between repositories
44 must be checked out from the repository for modification.
45 Checked out files are stored in a
47 which can be placed at an arbitrary directory in the filesystem hierarchy.
48 The on-disk format of this work tree is described in
52 provides global and command-specific options.
53 Global options must preceed the command name, and are as follows:
54 .Bl -tag -width tenletters
56 Display usage information.
62 .Bl -tag -width checkout
64 Create a new empty repository at the specified
71 command must be used to populate the empty repository before
75 .It Cm import [ Fl b Ar branch ] [ Fl m Ar message ] [ Fl r Ar repository-path ] [ Fl I Ar pattern ] directory
76 Create an initial commit in a repository from the file hierarchy
79 The created commit will not have any parent commits, i.e. it will be a
81 Also create a new reference which provides a branch name for the newly
83 Show the path of each imported file to indicate progress.
89 environment variable to be set.
98 instead of creating the default branch
100 Use of this option is required if the
102 branch already exists.
104 Use the specified log message when creating the new commit.
109 opens a temporary file in an editor where a log message can be written.
110 .It Fl r Ar repository-path
111 Use the repository at the specified path.
112 If not specified, assume the repository is located at or above the current
115 Ignore files or directories with a name which matches the specified
117 This option may be specified multiple times to build a list of ignore patterns.
120 follows the globbing rules documented in
123 .It Cm checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
124 Copy files from a repository into a new work tree.
127 is not specified, either use the last component of
128 .Ar repository path ,
131 was specified use the last component of
139 Check out files from the specified
141 If this option is not specified, a branch resolved via the repository's HEAD
142 reference will be used.
144 Check out files from the specified
146 The expected argument is a commit ID SHA1 hash.
147 An abbreviated hash argument will be expanded to a full SHA1 hash
148 automatically, provided the abbreviation is unique.
149 If this option is not specified, the most recent commit on the selected
151 .It Fl p Ar path-prefix
152 Restrict the work tree to a subset of the repository's tree hierarchy.
153 Only files beneath the specified
160 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
161 Update an existing work tree to a different commit.
162 Show the status of each affected file, using the following status codes:
163 .Bl -column YXZ description
164 .It U Ta file was updated and contained no local changes
165 .It G Ta file was updated and local changes were merged cleanly
166 .It C Ta file was updated and conflicts occurred during merge
167 .It D Ta file was deleted
168 .It A Ta new file was added
169 .It ~ Ta versioned file is obstructed by a non-regular file
170 .It ! Ta a missing versioned file was restored
175 is specified, restrict the update operation to files at or within this path.
176 The path is required to exist in the update operation's target commit.
177 Files in the work tree outside this path will remain unchanged and will
178 retain their previously recorded base commit.
181 commands may refuse to run while the work tree contains files from
182 multiple base commits.
183 The base commit of such a work tree can be made consistent by running
185 across the entire work tree.
188 is incompatible with the
197 Switch the work tree's branch reference to the specified
199 before updating the work tree.
200 This option requires that all paths in the work tree are updated.
202 Update the work tree to the specified
204 The expected argument is a commit ID SHA1 hash.
205 An abbreviated hash argument will be expanded to a full SHA1 hash
206 automatically, provided the abbreviation is unique.
207 If this option is not specified, the most recent commit on the work tree's
213 .It Cm status [ Ar path ]
214 Show the current modification status of files in a work tree,
215 using the following status codes:
216 .Bl -column YXZ description
217 .It M Ta modified file
218 .It A Ta file scheduled for addition in next commit
219 .It D Ta file scheduled for deletion in next commit
220 .It C Ta modified or added file which contains merge conflicts
221 .It ! Ta versioned file was expected on disk but is missing
222 .It ~ Ta versioned file is obstructed by a non-regular file
223 .It ? Ta unversioned item not tracked by
229 is specified, only show modifications within this path.
233 .It Cm log [ Fl c Ar commit ] [ Fl C Ar number ] [ Fl f ] [ Fl l Ar N ] [ Fl p ] [ Fl r Ar repository-path ] [ path ]
234 Display history of a repository.
237 is specified, show only commits which modified this path.
244 Start traversing history at the specified
246 The expected argument is the name of a branch or a commit ID SHA1 hash.
247 An abbreviated hash argument will be expanded to a full SHA1 hash
248 automatically, provided the abbreviation is unique.
249 If this option is not specified, default to the work tree's current branch
250 if invoked in a work tree, or to the repository's HEAD reference.
252 Set the number of context lines shown in diffs with
254 By default, 3 lines of context are shown.
256 Restrict history traversal to the first parent of each commit.
257 This shows the linear history of the current branch only.
258 Merge commits which affected the current branch will be shown but
259 individual commits which originated on other branches will be omitted.
261 Limit history traversal to a given number of commits.
263 Display the patch of modifications made in each commit.
264 .It Fl r Ar repository-path
265 Use the repository at the specified path.
266 If not specified, assume the repository is located at or above the current
268 If this directory is a
270 work tree, use the repository path associated with this work tree.
272 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
273 When invoked within a work tree with less than two arguments, display
274 uncommitted changes in the work tree.
277 is specified, only show changes within this path.
279 If two arguments are provided, treat each argument as a reference,
280 or an object ID SHA1 hash, and display differences between these objects.
281 Both objects must be of the same type (blobs, trees, or commits).
282 An abbreviated hash argument will be expanded to a full SHA1 hash
283 automatically, provided the abbreviation is unique.
290 Set the number of context lines shown in the diff.
291 By default, 3 lines of context are shown.
292 .It Fl r Ar repository-path
293 Use the repository at the specified path.
294 If not specified, assume the repository is located at or above the current
296 If this directory is a
298 work tree, use the repository path associated with this work tree.
300 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
301 Display line-by-line history of a file at the specified path.
308 Start traversing history at the specified
310 The expected argument is the name of a branch or a commit ID SHA1 hash.
311 An abbreviated hash argument will be expanded to a full SHA1 hash
312 automatically, provided the abbreviation is unique.
313 .It Fl r Ar repository-path
314 Use the repository at the specified path.
315 If not specified, assume the repository is located at or above the current
317 If this directory is a
319 work tree, use the repository path associated with this work tree.
321 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
322 Display a listing of files and directories at the specified
323 directory path in the repository.
324 Entries shown in this listing may carry one of the following trailing
326 .Bl -column YXZ description
327 .It / Ta entry is a directory
328 .It * Ta entry is an executable file
333 is specified, list the repository path corresponding to the current
334 directory of the work tree, or the root directory of the repository
335 if there is no work tree.
342 List files and directories as they appear in the specified
344 The expected argument is the name of a branch or a commit ID SHA1 hash.
345 An abbreviated hash argument will be expanded to a full SHA1 hash
346 automatically, provided the abbreviation is unique.
347 .It Fl r Ar repository-path
348 Use the repository at the specified path.
349 If not specified, assume the repository is located at or above the current
351 If this directory is a
353 work tree, use the repository path associated with this work tree.
355 Show object IDs of files (blob objects) and directories (tree objects).
357 Recurse into sub-directories in the repository.
359 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
360 Manage references in a repository.
362 If no options are passed, expect two arguments and attempt to create,
363 or update, the reference with the given
365 and make it point at the given
367 The target may be an object ID SHA1 hash or an existing reference which
368 will be resolved to an object ID.
369 An abbreviated hash argument will be expanded to a full SHA1 hash
370 automatically, provided the abbreviation is unique.
376 .It Fl r Ar repository-path
377 Use the repository at the specified path.
378 If not specified, assume the repository is located at or above the current
380 If this directory is a
382 work tree, use the repository path associated with this work tree.
384 List all existing references in the repository.
386 Delete the reference with the specified name from the repository.
388 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
389 Manage branches in a repository.
391 Branches are managed via references which live in the
396 command operates on references in this namespace only.
398 If no options are passed, expect one or two arguments and attempt to create
399 a branch with the given
401 and make it point at the given
405 is specified, default to the work tree's current branch if invoked in a
406 work tree, or to the repository's HEAD reference.
412 .It Fl r Ar repository-path
413 Use the repository at the specified path.
414 If not specified, assume the repository is located at or above the current
416 If this directory is a
418 work tree, use the repository path associated with this work tree.
420 List all existing branches in the repository.
421 If invoked in a work tree, the work tree's current branch is shown
422 with one the following annotations:
423 .Bl -column YXZ description
424 .It * Ta work tree's base commit matches the branch tip
425 .It ~ Ta work tree's base commit is out-of-date
428 Delete the branch with the specified name from the repository.
429 Only the branch reference is deleted.
430 Any commit, tree, and blob objects belonging to the branch
431 remain in the repository and may be removed separately with
432 Git's garbage collector.
437 .It Cm add Ar file-path ...
438 Schedule unversioned files in a work tree for addition to the
439 repository in the next commit.
440 .It Cm remove Ar file-path ...
441 Remove versioned files from a work tree and schedule them for deletion
442 from the repository in the next commit.
449 Perform the operation even if a file contains uncommitted modifications.
454 .It Cm revert Ar file-path ...
455 Revert any uncommited changes in files at the specified paths.
456 File contents will be overwritten with those contained in the
457 work tree's base commit. There is no way to bring discarded
461 If a file was added with
463 it will become an unversioned file again.
464 If a file was deleted with
470 .It Cm commit [ Fl m Ar message ] [ file-path ]
471 Create a new commit in the repository from local changes in a work tree
472 and use this commit as the new base commit for the work tree.
474 Show the status of each affected file, using the following status codes:
475 .Bl -column YXZ description
476 .It M Ta modified file
477 .It D Ta file was deleted
478 .It A Ta new file was added
481 Files without local changes will retain their previously recorded base
485 commands may refuse to run while the work tree contains files from
486 multiple base commits.
487 The base commit of such a work tree can be made consistent by running
489 across the entire work tree.
495 environment variable to be set.
502 Use the specified log message when creating the new commit.
507 opens a temporary file in an editor where a log message can be written.
512 .It Cm cherrypick Ar commit
513 Merge changes from a single
518 must be on a different branch than the work tree's base commit.
519 The expected argument is a reference or a commit ID SHA1 hash.
520 An abbreviated hash argument will be expanded to a full SHA1 hash
521 automatically, provided the abbreviation is unique.
523 Show the status of each affected file, using the following status codes:
524 .Bl -column YXZ description
525 .It G Ta file was merged
526 .It C Ta file was merged and conflicts occurred during merge
527 .It ! Ta changes destined for a missing file were not merged
528 .It D Ta file was deleted
529 .It d Ta file's deletion was obstructed by local modifications
530 .It A Ta new file was added
531 .It ~ Ta changes destined for a non-regular file were not merged
534 The merged changes will appear as local changes in the work tree, which
537 amended manually or with further
542 or discarded again with
546 will refuse to run if certain preconditions are not met.
547 If the work tree contains multiple base commits it must first be updated
548 to a single base commit with
550 If the work tree already contains files with merge conflicts, these
551 conflicts must be resolved first.
555 .It Cm backout Ar commit
556 Reverse-merge changes from a single
561 must be on the same branch as the work tree's base commit.
562 The expected argument is a reference or a commit ID SHA1 hash.
563 An abbreviated hash argument will be expanded to a full SHA1 hash
564 automatically, provided the abbreviation is unique.
566 Show the status of each affected file, using the following status codes:
567 .Bl -column YXZ description
568 .It G Ta file was merged
569 .It C Ta file was merged and conflicts occurred during merge
570 .It ! Ta changes destined for a missing file were not merged
571 .It D Ta file was deleted
572 .It d Ta file's deletion was obstructed by local modifications
573 .It A Ta new file was added
574 .It ~ Ta changes destined for a non-regular file were not merged
577 The reverse-merged changes will appear as local changes in the work tree,
578 which may be viewed with
580 amended manually or with further
585 or discarded again with
589 will refuse to run if certain preconditions are not met.
590 If the work tree contains multiple base commits it must first be updated
591 to a single base commit with
593 If the work tree already contains files with merge conflicts, these
594 conflicts must be resolved first.
598 .It Cm rebase [ Fl a ] [ Fl c] [ Ar branch ]
599 Rebase commits on the specified
601 onto the tip of the current branch of the work tree.
604 must share common ancestry with the work tree's current branch.
605 Rebasing begins with the first descendent commit of the youngest
606 common ancestor commit shared by the specified
608 and the work tree's current branch, and stops once the tip commit
613 Rebased commits are accumulated on a temporary branch and represent
614 the same changes with the same log messages as their counterparts
617 but with different commit IDs.
618 Once rebasing has completed successfully, the temporary branch becomes
619 the new version of the specified
621 and the work tree is automatically switched to it.
623 While rebasing commits, show the status of each affected file,
624 using the following status codes:
625 .Bl -column YXZ description
626 .It G Ta file was merged
627 .It C Ta file was merged and conflicts occurred during merge
628 .It ! Ta changes destined for a missing file were not merged
629 .It D Ta file was deleted
630 .It d Ta file's deletion was obstructed by local modifications
631 .It A Ta new file was added
632 .It ~ Ta changes destined for a non-regular file were not merged
635 If merge conflicts occur the rebase operation is interrupted and may
636 be continued once conflicts have been resolved.
637 Alternatively, the rebase operation may be aborted which will leave
639 unmodified and the work tree switched back to its original branch.
641 If a merge conflict is resolved in a way which renders the merged
642 change into a no-op change, the corresponding commit will be elided
643 when the rebase operation continues.
646 will refuse to run if certain preconditions are not met.
647 If the work tree contains multiple base commits it must first be updated
648 to a single base commit with
650 If the work tree contains local changes, these changes must first be
657 contains changes to files outside of the work tree's path prefix,
658 the work tree cannot be used to rebase this branch.
664 commands will refuse to run while a rebase operation is in progress.
665 Other commands which manipulate the work tree may be used for
666 conflict resolution purposes.
673 Abort an interrupted rebase operation.
674 If this option is used, no further command-line arguments are allowed.
676 Continue an interrupted rebase operation.
677 If this option is used, no further command-line arguments are allowed.
682 .It Cm histedit [ Fl a ] [ Fl c] [ Fl F Ar histedit-script ]
683 Edit commit history between the work tree's current base commit and
684 the tip commit of the work tree's current branch.
686 Editing of commit history is controlled via a
688 which can be edited interactively or passed on the command line.
689 The format of the histedit script is line-based.
690 Each line in the script begins with a command name, followed by
691 whitespace and an argument.
692 For most commands, the expected argument is a commit ID SHA1 hash.
693 Any remaining text on the line is ignored.
694 Lines which begin with the
696 character are ignored entirely.
698 The available commands are as follows:
699 .Bl -column YXZ pick-commit
700 .It pick Ar commit Ta Use the specified commit as it is.
701 .It edit Ar commit Ta Use the specfified commit but once changes have been
702 merged into the work tree interrupt the histedit operation for amending.
703 .It fold Ar commit Ta Combine the specified commit with the next commit
704 listed further below that will be used.
705 .It drop Ar commit Ta Remove this commit from the edited history.
706 .It mesg Ar log-message Ta Use the specified single-line log message for
707 the commit on the previous line.
708 If the log message argument is left empty, open an editor where a new
709 log message can be written.
712 Every commit in the history being edited must be mentioned in histedit script.
713 Lines may be re-ordered to change the order of commits in the edited history.
715 Edited commits are accumulated on a temporary branch.
716 Once history editing has completed successfully, the temporary branch becomes
717 the new version of the work tree's base branch and the work tree is
718 automatically switched to it.
720 While merging commits, show the status of each affected file,
721 using the following status codes:
722 .Bl -column YXZ description
723 .It G Ta file was merged
724 .It C Ta file was merged and conflicts occurred during merge
725 .It ! Ta changes destined for a missing file were not merged
726 .It D Ta file was deleted
727 .It d Ta file's deletion was obstructed by local modifications
728 .It A Ta new file was added
729 .It ~ Ta changes destined for a non-regular file were not merged
732 If merge conflicts occur the histedit operation is interrupted and may
733 be continued once conflicts have been resolved.
734 Alternatively, the histedit operation may be aborted which will leave
735 the work tree switched back to its original branch.
737 If a merge conflict is resolved in a way which renders the merged
738 change into a no-op change, the corresponding commit will be elided
739 when the histedit operation continues.
742 will refuse to run if certain preconditions are not met.
743 If the work tree contains multiple base commits it must first be updated
744 to a single base commit with
746 If the work tree contains local changes, these changes must first be
751 If the edited history contains changes to files outside of the work tree's
752 path prefix, the work tree cannot be used to edit the history of this branch.
758 commands will refuse to run while a histedit operation is in progress.
759 Other commands which manipulate the work tree may be used for
760 conflict resolution purposes.
767 Abort an interrupted histedit operation.
768 If this option is used, no further command-line arguments are allowed.
770 Continue an interrupted histedit operation.
771 If this option is used, no further command-line arguments are allowed.
778 .Bl -tag -width GOT_AUTHOR
780 The author's name and email address for
785 .An Stefan Sperling Aq Mt stsp@openbsd.org
786 .It Ev VISUAL, Ev EDITOR
787 The editor spawned by
793 Clone an existing Git repository for use with
795 This step currently requires
799 .Dl $ git clone --bare https://github.com/openbsd/src.git
801 Alternatively, for quick and dirty local testing of
803 a new Git repository could be created and populated with files,
804 e.g. from a temporary CVS checkout located at
807 .Dl $ got init /var/git/src.git
808 .Dl $ got import -r /var/git/src.git -I CVS -I obj /tmp/src
810 Check out a work tree from the Git repository to /usr/src:
812 .Dl $ got checkout /var/git/src.git /usr/src
814 View local changes in a work tree directory:
817 .Dl $ got diff | less
819 In a work tree or a git repository directory, list all branch references:
823 In a work tree or a git repository directory, create a new branch called
824 .Dq unified-buffer-cache
825 which is forked off the
829 .Dl $ got branch unified-buffer-cache master
831 Switch an existing work tree to the branch
832 .Dq unified-buffer-cache .
833 Local changes in the work tree will be preserved and merged if necessary:
835 .Dl $ got update -b unified-buffer-cache
837 Create a new commit from local changes in a work tree directory.
838 This new commit will become the head commit of the work tree's current branch:
842 In a work tree or a git repository directory, view changes committed in
843 the 3 most recent commits to the work tree's branch, or the branch resolved
844 via the repository's HEAD reference, respectively:
846 .Dl $ got log -p -l 3 -f
848 Add new files and remove obsolete files in a work tree directory:
850 .Dl $ got add sys/uvm/uvm_ubc.c
851 .Dl $ got remove sys/uvm/uvm_vnode.c
853 Create a new commit from local changes in a work tree directory
854 with a pre-defined log message.
856 .Dl $ got commit -m 'unify the buffer cache'
858 Update any work tree checked out from the
859 .Dq unified-buffer-cache
860 branch to the latest commit on this branch:
864 Roll file content on the unified-buffer-cache branch back by one commit,
865 and then fetch the rolled-back change into the work tree as a local change
866 to be amended and perhaps committed again:
868 .Dl $ got backout unified-buffer-cache
869 .Dl $ got commit -m 'roll back previous'
870 .Dl $ # now back out the previous backout :-)
871 .Dl $ got backout unified-buffer-cache
873 Fetch new upstream commits into the local repository's master branch.
874 This step currently requires
877 .Dl $ cd /var/git/src.git
878 .Dl $ git fetch origin master:master
881 .Dq unified-buffer-cache
882 branch on top of the new head commit of the
886 .Dl $ got update -b master
887 .Dl $ got rebase unified-buffer-cache
889 Create a patch from all changes on the unified-buffer-cache branch.
890 The patch can be mailed out for review and applied to OpenBSD's CVS tree:
892 .Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff
894 Edit the entire commit history of the
895 .Dq unified-buffer-cache
898 .Dl $ got update -b unified-buffer-cache
899 .Dl $ got update -c master
904 .Xr git-repository 5 ,
907 .An Stefan Sperling Aq Mt stsp@openbsd.org
908 .An Martin Pieuchot Aq Mt mpi@openbsd.org
909 .An joshua stein Aq Mt jcs@openbsd.org
912 is a work-in-progress and many commands remain to be implemented.
913 At present, the user has to fall back on
915 to perform tasks related to repository administration and tasks
916 which require a network connection.
918 When working against a repository created with
919 .Dq git clone --bare ,
922 branch are discouraged, for now, if changes committed to the upstream
923 repository need to be tracked.
924 See the EXAMPLES section.
929 commands should alleviate this problem.