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 or an existing reference
147 which will be resolved to a commit ID.
148 An abbreviated hash argument will be expanded to a full SHA1 hash
149 automatically, provided the abbreviation is unique.
150 If this option is not specified, the most recent commit on the selected
152 .It Fl p Ar path-prefix
153 Restrict the work tree to a subset of the repository's tree hierarchy.
154 Only files beneath the specified
161 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
162 Update an existing work tree to a different commit.
163 Show the status of each affected file, using the following status codes:
164 .Bl -column YXZ description
165 .It U Ta file was updated and contained no local changes
166 .It G Ta file was updated and local changes were merged cleanly
167 .It C Ta file was updated and conflicts occurred during merge
168 .It D Ta file was deleted
169 .It A Ta new file was added
170 .It ~ Ta versioned file is obstructed by a non-regular file
171 .It ! Ta a missing versioned file was restored
176 is specified, restrict the update operation to files at or within this path.
177 The path is required to exist in the update operation's target commit.
178 Files in the work tree outside this path will remain unchanged and will
179 retain their previously recorded base commit.
182 commands may refuse to run while the work tree contains files from
183 multiple base commits.
184 The base commit of such a work tree can be made consistent by running
186 across the entire work tree.
189 is incompatible with the
198 Switch the work tree's branch reference to the specified
200 before updating the work tree.
201 This option requires that all paths in the work tree are updated.
203 Update the work tree to the specified
205 The expected argument is a commit ID SHA1 hash or an existing reference
206 which will be resolved to a commit ID.
207 An abbreviated hash argument will be expanded to a full SHA1 hash
208 automatically, provided the abbreviation is unique.
209 If this option is not specified, the most recent commit on the work tree's
215 .It Cm status [ Ar path ]
216 Show the current modification status of files in a work tree,
217 using the following status codes:
218 .Bl -column YXZ description
219 .It M Ta modified file
220 .It A Ta file scheduled for addition in next commit
221 .It D Ta file scheduled for deletion in next commit
222 .It C Ta modified or added file which contains merge conflicts
223 .It ! Ta versioned file was expected on disk but is missing
224 .It ~ Ta versioned file is obstructed by a non-regular file
225 .It ? Ta unversioned item not tracked by
231 is specified, only show modifications within this path.
235 .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 ]
236 Display history of a repository.
239 is specified, show only commits which modified this path.
246 Start traversing history at the specified
248 The expected argument is a commit ID SHA1 hash or an existing reference
249 which will be resolved to a commit ID.
250 An abbreviated hash argument will be expanded to a full SHA1 hash
251 automatically, provided the abbreviation is unique.
252 If this option is not specified, default to the work tree's current branch
253 if invoked in a work tree, or to the repository's HEAD reference.
255 Set the number of context lines shown in diffs with
257 By default, 3 lines of context are shown.
259 Restrict history traversal to the first parent of each commit.
260 This shows the linear history of the current branch only.
261 Merge commits which affected the current branch will be shown but
262 individual commits which originated on other branches will be omitted.
264 Limit history traversal to a given number of commits.
266 Display the patch of modifications made in each commit.
267 .It Fl r Ar repository-path
268 Use the repository at the specified path.
269 If not specified, assume the repository is located at or above the current
271 If this directory is a
273 work tree, use the repository path associated with this work tree.
275 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
276 When invoked within a work tree with less than two arguments, display
277 uncommitted changes in the work tree.
280 is specified, only show changes within this path.
282 If two arguments are provided, treat each argument as a reference,
283 or an object ID SHA1 hash, and display differences between these objects.
284 Both objects must be of the same type (blobs, trees, or commits).
285 An abbreviated hash argument will be expanded to a full SHA1 hash
286 automatically, provided the abbreviation is unique.
293 Set the number of context lines shown in the diff.
294 By default, 3 lines of context are shown.
295 .It Fl r Ar repository-path
296 Use the repository at the specified path.
297 If not specified, assume the repository is located at or above the current
299 If this directory is a
301 work tree, use the repository path associated with this work tree.
303 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
304 Display line-by-line history of a file at the specified path.
311 Start traversing history at the specified
313 The expected argument is a commit ID SHA1 hash or an existing reference
314 which will be resolved to a commit ID.
315 An abbreviated hash argument will be expanded to a full SHA1 hash
316 automatically, provided the abbreviation is unique.
317 .It Fl r Ar repository-path
318 Use the repository at the specified path.
319 If not specified, assume the repository is located at or above the current
321 If this directory is a
323 work tree, use the repository path associated with this work tree.
325 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
326 Display a listing of files and directories at the specified
327 directory path in the repository.
328 Entries shown in this listing may carry one of the following trailing
330 .Bl -column YXZ description
331 .It / Ta entry is a directory
332 .It * Ta entry is an executable file
337 is specified, list the repository path corresponding to the current
338 directory of the work tree, or the root directory of the repository
339 if there is no work tree.
346 List files and directories as they appear in the specified
348 The expected argument is a commit ID SHA1 hash or an existing reference
349 which will be resolved to a commit ID.
350 An abbreviated hash argument will be expanded to a full SHA1 hash
351 automatically, provided the abbreviation is unique.
352 .It Fl r Ar repository-path
353 Use the repository at the specified path.
354 If not specified, assume the repository is located at or above the current
356 If this directory is a
358 work tree, use the repository path associated with this work tree.
360 Show object IDs of files (blob objects) and directories (tree objects).
362 Recurse into sub-directories in the repository.
364 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
365 Manage references in a repository.
367 If no options are passed, expect two arguments and attempt to create,
368 or update, the reference with the given
370 and make it point at the given
372 The target may be an object ID SHA1 hash or an existing reference which
373 will be resolved to an object ID.
374 An abbreviated hash argument will be expanded to a full SHA1 hash
375 automatically, provided the abbreviation is unique.
381 .It Fl r Ar repository-path
382 Use the repository at the specified path.
383 If not specified, assume the repository is located at or above the current
385 If this directory is a
387 work tree, use the repository path associated with this work tree.
389 List all existing references in the repository.
391 Delete the reference with the specified name from the repository.
393 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
394 Manage branches in a repository.
396 Branches are managed via references which live in the
401 command operates on references in this namespace only.
403 If no options are passed, expect one or two arguments and attempt to create
404 a branch with the given
406 and make it point at the given
410 is specified, default to the work tree's current branch if invoked in a
411 work tree, or to the repository's HEAD reference.
417 .It Fl r Ar repository-path
418 Use the repository at the specified path.
419 If not specified, assume the repository is located at or above the current
421 If this directory is a
423 work tree, use the repository path associated with this work tree.
425 List all existing branches in the repository.
426 If invoked in a work tree, the work tree's current branch is shown
427 with one the following annotations:
428 .Bl -column YXZ description
429 .It * Ta work tree's base commit matches the branch tip
430 .It ~ Ta work tree's base commit is out-of-date
433 Delete the branch with the specified name from the repository.
434 Only the branch reference is deleted.
435 Any commit, tree, and blob objects belonging to the branch
436 remain in the repository and may be removed separately with
437 Git's garbage collector.
442 .It Cm add Ar file-path ...
443 Schedule unversioned files in a work tree for addition to the
444 repository in the next commit.
445 .It Cm remove Ar file-path ...
446 Remove versioned files from a work tree and schedule them for deletion
447 from the repository in the next commit.
454 Perform the operation even if a file contains uncommitted modifications.
459 .It Cm revert Ar file-path ...
460 Revert any uncommited changes in files at the specified paths.
461 File contents will be overwritten with those contained in the
462 work tree's base commit. There is no way to bring discarded
466 If a file was added with
468 it will become an unversioned file again.
469 If a file was deleted with
475 .It Cm commit [ Fl m Ar message ] [ file-path ]
476 Create a new commit in the repository from local changes in a work tree
477 and use this commit as the new base commit for the work tree.
479 Show the status of each affected file, using the following status codes:
480 .Bl -column YXZ description
481 .It M Ta modified file
482 .It D Ta file was deleted
483 .It A Ta new file was added
486 Files without local changes will retain their previously recorded base
490 commands may refuse to run while the work tree contains files from
491 multiple base commits.
492 The base commit of such a work tree can be made consistent by running
494 across the entire work tree.
500 environment variable to be set.
507 Use the specified log message when creating the new commit.
512 opens a temporary file in an editor where a log message can be written.
517 .It Cm cherrypick Ar commit
518 Merge changes from a single
523 must be on a different branch than the work tree's base commit.
524 The expected argument is a reference or a commit ID SHA1 hash.
525 An abbreviated hash argument will be expanded to a full SHA1 hash
526 automatically, provided the abbreviation is unique.
528 Show the status of each affected file, using the following status codes:
529 .Bl -column YXZ description
530 .It G Ta file was merged
531 .It C Ta file was merged and conflicts occurred during merge
532 .It ! Ta changes destined for a missing file were not merged
533 .It D Ta file was deleted
534 .It d Ta file's deletion was obstructed by local modifications
535 .It A Ta new file was added
536 .It ~ Ta changes destined for a non-regular file were not merged
539 The merged changes will appear as local changes in the work tree, which
542 amended manually or with further
547 or discarded again with
551 will refuse to run if certain preconditions are not met.
552 If the work tree contains multiple base commits it must first be updated
553 to a single base commit with
555 If the work tree already contains files with merge conflicts, these
556 conflicts must be resolved first.
560 .It Cm backout Ar commit
561 Reverse-merge changes from a single
566 must be on the same branch as the work tree's base commit.
567 The expected argument is a reference or a commit ID SHA1 hash.
568 An abbreviated hash argument will be expanded to a full SHA1 hash
569 automatically, provided the abbreviation is unique.
571 Show the status of each affected file, using the following status codes:
572 .Bl -column YXZ description
573 .It G Ta file was merged
574 .It C Ta file was merged and conflicts occurred during merge
575 .It ! Ta changes destined for a missing file were not merged
576 .It D Ta file was deleted
577 .It d Ta file's deletion was obstructed by local modifications
578 .It A Ta new file was added
579 .It ~ Ta changes destined for a non-regular file were not merged
582 The reverse-merged changes will appear as local changes in the work tree,
583 which may be viewed with
585 amended manually or with further
590 or discarded again with
594 will refuse to run if certain preconditions are not met.
595 If the work tree contains multiple base commits it must first be updated
596 to a single base commit with
598 If the work tree already contains files with merge conflicts, these
599 conflicts must be resolved first.
603 .It Cm rebase [ Fl a ] [ Fl c] [ Ar branch ]
604 Rebase commits on the specified
606 onto the tip of the current branch of the work tree.
609 must share common ancestry with the work tree's current branch.
610 Rebasing begins with the first descendent commit of the youngest
611 common ancestor commit shared by the specified
613 and the work tree's current branch, and stops once the tip commit
618 Rebased commits are accumulated on a temporary branch and represent
619 the same changes with the same log messages as their counterparts
622 but with different commit IDs.
623 Once rebasing has completed successfully, the temporary branch becomes
624 the new version of the specified
626 and the work tree is automatically switched to it.
628 While rebasing commits, show the status of each affected file,
629 using the following status codes:
630 .Bl -column YXZ description
631 .It G Ta file was merged
632 .It C Ta file was merged and conflicts occurred during merge
633 .It ! Ta changes destined for a missing file were not merged
634 .It D Ta file was deleted
635 .It d Ta file's deletion was obstructed by local modifications
636 .It A Ta new file was added
637 .It ~ Ta changes destined for a non-regular file were not merged
640 If merge conflicts occur the rebase operation is interrupted and may
641 be continued once conflicts have been resolved.
642 Alternatively, the rebase operation may be aborted which will leave
644 unmodified and the work tree switched back to its original branch.
646 If a merge conflict is resolved in a way which renders the merged
647 change into a no-op change, the corresponding commit will be elided
648 when the rebase operation continues.
651 will refuse to run if certain preconditions are not met.
652 If the work tree contains multiple base commits it must first be updated
653 to a single base commit with
655 If the work tree contains local changes, these changes must first be
662 contains changes to files outside of the work tree's path prefix,
663 the work tree cannot be used to rebase this branch.
669 commands will refuse to run while a rebase operation is in progress.
670 Other commands which manipulate the work tree may be used for
671 conflict resolution purposes.
678 Abort an interrupted rebase operation.
679 If this option is used, no further command-line arguments are allowed.
681 Continue an interrupted rebase operation.
682 If this option is used, no further command-line arguments are allowed.
687 .It Cm histedit [ Fl a ] [ Fl c] [ Fl F Ar histedit-script ]
688 Edit commit history between the work tree's current base commit and
689 the tip commit of the work tree's current branch.
691 Editing of commit history is controlled via a
693 which can be edited interactively or passed on the command line.
694 The format of the histedit script is line-based.
695 Each line in the script begins with a command name, followed by
696 whitespace and an argument.
697 For most commands, the expected argument is a commit ID SHA1 hash.
698 Any remaining text on the line is ignored.
699 Lines which begin with the
701 character are ignored entirely.
703 The available commands are as follows:
704 .Bl -column YXZ pick-commit
705 .It pick Ar commit Ta Use the specified commit as it is.
706 .It edit Ar commit Ta Use the specified commit but once changes have been
707 merged into the work tree interrupt the histedit operation for amending.
708 .It fold Ar commit Ta Combine the specified commit with the next commit
709 listed further below that will be used.
710 .It drop Ar commit Ta Remove this commit from the edited history.
711 .It mesg Ar log-message Ta Use the specified single-line log message for
712 the commit on the previous line.
713 If the log message argument is left empty, open an editor where a new
714 log message can be written.
717 Every commit in the history being edited must be mentioned in histedit script.
718 Lines may be re-ordered to change the order of commits in the edited history.
720 Edited commits are accumulated on a temporary branch.
721 Once history editing has completed successfully, the temporary branch becomes
722 the new version of the work tree's base branch and the work tree is
723 automatically switched to it.
725 While merging commits, show the status of each affected file,
726 using the following status codes:
727 .Bl -column YXZ description
728 .It G Ta file was merged
729 .It C Ta file was merged and conflicts occurred during merge
730 .It ! Ta changes destined for a missing file were not merged
731 .It D Ta file was deleted
732 .It d Ta file's deletion was obstructed by local modifications
733 .It A Ta new file was added
734 .It ~ Ta changes destined for a non-regular file were not merged
737 If merge conflicts occur the histedit operation is interrupted and may
738 be continued once conflicts have been resolved.
739 Alternatively, the histedit operation may be aborted which will leave
740 the work tree switched back to its original branch.
742 If a merge conflict is resolved in a way which renders the merged
743 change into a no-op change, the corresponding commit will be elided
744 when the histedit operation continues.
747 will refuse to run if certain preconditions are not met.
748 If the work tree contains multiple base commits it must first be updated
749 to a single base commit with
751 If the work tree contains local changes, these changes must first be
756 If the edited history contains changes to files outside of the work tree's
757 path prefix, the work tree cannot be used to edit the history of this branch.
761 command will refuse to run while a histedit operation is in progress.
762 Other commands which manipulate the work tree may be used, and the
764 command may be used to commit arbitrary changes to the temporary branch
765 while the histedit operation is interrupted.
772 Abort an interrupted histedit operation.
773 If this option is used, no further command-line arguments are allowed.
775 Continue an interrupted histedit operation.
776 If this option is used, no further command-line arguments are allowed.
783 .Bl -tag -width GOT_AUTHOR
785 The author's name and email address for
790 .An Stefan Sperling Aq Mt stsp@openbsd.org
791 .It Ev VISUAL, Ev EDITOR
792 The editor spawned by
798 Clone an existing Git repository for use with
800 This step currently requires
804 .Dl $ git clone --bare https://github.com/openbsd/src.git
806 Alternatively, for quick and dirty local testing of
808 a new Git repository could be created and populated with files,
809 e.g. from a temporary CVS checkout located at
812 .Dl $ got init /var/git/src.git
813 .Dl $ got import -r /var/git/src.git -I CVS -I obj /tmp/src
815 Check out a work tree from the Git repository to /usr/src:
817 .Dl $ got checkout /var/git/src.git /usr/src
819 View local changes in a work tree directory:
822 .Dl $ got diff | less
824 In a work tree or a git repository directory, list all branch references:
828 In a work tree or a git repository directory, create a new branch called
829 .Dq unified-buffer-cache
830 which is forked off the
834 .Dl $ got branch unified-buffer-cache master
836 Switch an existing work tree to the branch
837 .Dq unified-buffer-cache .
838 Local changes in the work tree will be preserved and merged if necessary:
840 .Dl $ got update -b unified-buffer-cache
842 Create a new commit from local changes in a work tree directory.
843 This new commit will become the head commit of the work tree's current branch:
847 In a work tree or a git repository directory, view changes committed in
848 the 3 most recent commits to the work tree's branch, or the branch resolved
849 via the repository's HEAD reference, respectively:
851 .Dl $ got log -p -l 3 -f
853 Add new files and remove obsolete files in a work tree directory:
855 .Dl $ got add sys/uvm/uvm_ubc.c
856 .Dl $ got remove sys/uvm/uvm_vnode.c
858 Create a new commit from local changes in a work tree directory
859 with a pre-defined log message.
861 .Dl $ got commit -m 'unify the buffer cache'
863 Update any work tree checked out from the
864 .Dq unified-buffer-cache
865 branch to the latest commit on this branch:
869 Roll file content on the unified-buffer-cache branch back by one commit,
870 and then fetch the rolled-back change into the work tree as a local change
871 to be amended and perhaps committed again:
873 .Dl $ got backout unified-buffer-cache
874 .Dl $ got commit -m 'roll back previous'
875 .Dl $ # now back out the previous backout :-)
876 .Dl $ got backout unified-buffer-cache
878 Fetch new upstream commits into the local repository's master branch.
879 This step currently requires
882 .Dl $ cd /var/git/src.git
883 .Dl $ git fetch origin master:master
886 .Dq unified-buffer-cache
887 branch on top of the new head commit of the
891 .Dl $ got update -b master
892 .Dl $ got rebase unified-buffer-cache
894 Create a patch from all changes on the unified-buffer-cache branch.
895 The patch can be mailed out for review and applied to OpenBSD's CVS tree:
897 .Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff
899 Edit the entire commit history of the
900 .Dq unified-buffer-cache
903 .Dl $ got update -b unified-buffer-cache
904 .Dl $ got update -c master
909 .Xr git-repository 5 ,
912 .An Stefan Sperling Aq Mt stsp@openbsd.org
913 .An Martin Pieuchot Aq Mt mpi@openbsd.org
914 .An joshua stein Aq Mt jcs@openbsd.org
917 is a work-in-progress and many commands remain to be implemented.
918 At present, the user has to fall back on
920 to perform tasks related to repository administration and tasks
921 which require a network connection.
923 When working against a repository created with
924 .Dq git clone --bare ,
927 branch are discouraged, for now, if changes committed to the upstream
928 repository need to be tracked.
929 See the EXAMPLES section.
934 commands should alleviate this problem.