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
63 .It Cm init Ar repository-path
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 a commit on 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 on the selected branch.
147 The expected argument is a commit ID SHA1 hash or an existing reference
148 which will be resolved to a commit ID.
149 An abbreviated hash argument will be expanded to a full SHA1 hash
150 automatically, provided the abbreviation is unique.
151 If this option is not specified, the most recent commit on the selected
153 .It Fl p Ar path-prefix
154 Restrict the work tree to a subset of the repository's tree hierarchy.
155 Only files beneath the specified
162 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ... ]
163 Update an existing work tree to a different commit.
164 Show the status of each affected file, using the following status codes:
165 .Bl -column YXZ description
166 .It U Ta file was updated and contained no local changes
167 .It G Ta file was updated and local changes were merged cleanly
168 .It C Ta file was updated and conflicts occurred during merge
169 .It D Ta file was deleted
170 .It A Ta new file was added
171 .It ~ Ta versioned file is obstructed by a non-regular file
172 .It ! Ta a missing versioned file was restored
177 is specified, update the entire work tree.
178 Otherwise, restrict the update operation to files at or within the
180 Each path is required to exist in the update operation's target commit.
181 Files in the work tree outside specified paths will remain unchanged and
182 will retain their previously recorded base commit.
185 commands may refuse to run while the work tree contains files from
186 multiple base commits.
187 The base commit of such a work tree can be made consistent by running
189 across the entire work tree.
192 is incompatible with the
201 Switch the work tree's branch reference to the specified
203 before updating the work tree.
204 This option requires that all paths in the work tree are updated.
206 Update the work tree to the specified
208 The expected argument is a commit ID SHA1 hash or an existing reference
209 which will be resolved to a commit ID.
210 An abbreviated hash argument will be expanded to a full SHA1 hash
211 automatically, provided the abbreviation is unique.
212 If this option is not specified, the most recent commit on the work tree's
218 .It Cm status [ Ar path ... ]
219 Show the current modification status of files in a work tree,
220 using the following status codes:
221 .Bl -column YXZ description
222 .It M Ta modified file
223 .It A Ta file scheduled for addition in next commit
224 .It D Ta file scheduled for deletion in next commit
225 .It C Ta modified or added file which contains merge conflicts
226 .It ! Ta versioned file was expected on disk but is missing
227 .It ~ Ta versioned file is obstructed by a non-regular file
228 .It ? Ta unversioned item not tracked by
234 is specified, show modifications in the entire work tree.
235 Otherwise, show modifications at or within the specified paths.
239 .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 ]
240 Display history of a repository.
243 is specified, show only commits which modified this path.
250 Start traversing history at the specified
252 The expected argument is a commit ID SHA1 hash or an existing reference
253 which will be resolved to a commit ID.
254 An abbreviated hash argument will be expanded to a full SHA1 hash
255 automatically, provided the abbreviation is unique.
256 If this option is not specified, default to the work tree's current branch
257 if invoked in a work tree, or to the repository's HEAD reference.
259 Set the number of context lines shown in diffs with
261 By default, 3 lines of context are shown.
263 Restrict history traversal to the first parent of each commit.
264 This shows the linear history of the current branch only.
265 Merge commits which affected the current branch will be shown but
266 individual commits which originated on other branches will be omitted.
268 Limit history traversal to a given number of commits.
270 Display the patch of modifications made in each commit.
271 .It Fl r Ar repository-path
272 Use the repository at the specified path.
273 If not specified, assume the repository is located at or above the current
275 If this directory is a
277 work tree, use the repository path associated with this work tree.
279 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
280 When invoked within a work tree with less than two arguments, display
281 uncommitted changes in the work tree.
284 is specified, only show changes within this path.
286 If two arguments are provided, treat each argument as a reference,
287 or an object ID SHA1 hash, and display differences between these objects.
288 Both objects must be of the same type (blobs, trees, or commits).
289 An abbreviated hash argument will be expanded to a full SHA1 hash
290 automatically, provided the abbreviation is unique.
297 Set the number of context lines shown in the diff.
298 By default, 3 lines of context are shown.
299 .It Fl r Ar repository-path
300 Use the repository at the specified path.
301 If not specified, assume the repository is located at or above the current
303 If this directory is a
305 work tree, use the repository path associated with this work tree.
307 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
308 Display line-by-line history of a file at the specified path.
315 Start traversing history at the specified
317 The expected argument is a commit ID SHA1 hash or an existing reference
318 which will be resolved to a commit ID.
319 An abbreviated hash argument will be expanded to a full SHA1 hash
320 automatically, provided the abbreviation is unique.
321 .It Fl r Ar repository-path
322 Use the repository at the specified path.
323 If not specified, assume the repository is located at or above the current
325 If this directory is a
327 work tree, use the repository path associated with this work tree.
329 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
330 Display a listing of files and directories at the specified
331 directory path in the repository.
332 Entries shown in this listing may carry one of the following trailing
334 .Bl -column YXZ description
335 .It / Ta entry is a directory
336 .It * Ta entry is an executable file
341 is specified, list the repository path corresponding to the current
342 directory of the work tree, or the root directory of the repository
343 if there is no work tree.
350 List files and directories as they appear in the specified
352 The expected argument is a commit ID SHA1 hash or an existing reference
353 which will be resolved to a commit ID.
354 An abbreviated hash argument will be expanded to a full SHA1 hash
355 automatically, provided the abbreviation is unique.
356 .It Fl r Ar repository-path
357 Use the repository at the specified path.
358 If not specified, assume the repository is located at or above the current
360 If this directory is a
362 work tree, use the repository path associated with this work tree.
364 Show object IDs of files (blob objects) and directories (tree objects).
366 Recurse into sub-directories in the repository.
368 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
369 Manage references in a repository.
371 If no options are passed, expect two arguments and attempt to create,
372 or update, the reference with the given
374 and make it point at the given
376 The target may be an object ID SHA1 hash or an existing reference which
377 will be resolved to an object ID.
378 An abbreviated hash argument will be expanded to a full SHA1 hash
379 automatically, provided the abbreviation is unique.
385 .It Fl r Ar repository-path
386 Use the repository at the specified path.
387 If not specified, assume the repository is located at or above the current
389 If this directory is a
391 work tree, use the repository path associated with this work tree.
393 List all existing references in the repository.
395 Delete the reference with the specified name from the repository.
397 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
398 Manage branches in a repository.
400 Branches are managed via references which live in the
405 command operates on references in this namespace only.
407 If no options are passed, expect one or two arguments and attempt to create
408 a branch with the given
410 and make it point at the given
414 is specified, default to the work tree's current branch if invoked in a
415 work tree, or to the repository's HEAD reference.
421 .It Fl r Ar repository-path
422 Use the repository at the specified path.
423 If not specified, assume the repository is located at or above the current
425 If this directory is a
427 work tree, use the repository path associated with this work tree.
429 List all existing branches in the repository.
430 If invoked in a work tree, the work tree's current branch is shown
431 with one the following annotations:
432 .Bl -column YXZ description
433 .It * Ta work tree's base commit matches the branch tip
434 .It ~ Ta work tree's base commit is out-of-date
437 Delete the branch with the specified name from the repository.
438 Only the branch reference is deleted.
439 Any commit, tree, and blob objects belonging to the branch
440 remain in the repository and may be removed separately with
441 Git's garbage collector.
446 .It Cm add Ar file-path ...
447 Schedule unversioned files in a work tree for addition to the
448 repository in the next commit.
449 .It Cm remove Ar file-path ...
450 Remove versioned files from a work tree and schedule them for deletion
451 from the repository in the next commit.
458 Perform the operation even if a file contains uncommitted modifications.
463 .It Cm revert Ar file-path ...
464 Revert any uncommited changes in files at the specified paths.
465 File contents will be overwritten with those contained in the
466 work tree's base commit. There is no way to bring discarded
470 If a file was added with
472 it will become an unversioned file again.
473 If a file was deleted with
479 .It Cm commit [ Fl m Ar message ] [ path ... ]
480 Create a new commit in the repository from local changes in a work tree
481 and use this commit as the new base commit for the work tree.
484 is specified, commit all local changes in the work tree.
485 Otherwise, commit local changes at or within the specified paths.
487 Show the status of each affected file, using the following status codes:
488 .Bl -column YXZ description
489 .It M Ta modified file
490 .It D Ta file was deleted
491 .It A Ta new file was added
494 Files without local changes will retain their previously recorded base
498 commands may refuse to run while the work tree contains files from
499 multiple base commits.
500 The base commit of such a work tree can be made consistent by running
502 across the entire work tree.
508 environment variable to be set.
515 Use the specified log message when creating the new commit.
520 opens a temporary file in an editor where a log message can be written.
525 .It Cm cherrypick Ar commit
526 Merge changes from a single
531 must be on a different branch than the work tree's base commit.
532 The expected argument is a reference or a commit ID SHA1 hash.
533 An abbreviated hash argument will be expanded to a full SHA1 hash
534 automatically, provided the abbreviation is unique.
536 Show the status of each affected file, using the following status codes:
537 .Bl -column YXZ description
538 .It G Ta file was merged
539 .It C Ta file was merged and conflicts occurred during merge
540 .It ! Ta changes destined for a missing file were not merged
541 .It D Ta file was deleted
542 .It d Ta file's deletion was obstructed by local modifications
543 .It A Ta new file was added
544 .It ~ Ta changes destined for a non-regular file were not merged
547 The merged changes will appear as local changes in the work tree, which
550 amended manually or with further
555 or discarded again with
559 will refuse to run if certain preconditions are not met.
560 If the work tree contains multiple base commits it must first be updated
561 to a single base commit with
563 If the work tree already contains files with merge conflicts, these
564 conflicts must be resolved first.
568 .It Cm backout Ar commit
569 Reverse-merge changes from a single
574 must be on the same branch as the work tree's base commit.
575 The expected argument is a reference or a commit ID SHA1 hash.
576 An abbreviated hash argument will be expanded to a full SHA1 hash
577 automatically, provided the abbreviation is unique.
579 Show the status of each affected file, using the following status codes:
580 .Bl -column YXZ description
581 .It G Ta file was merged
582 .It C Ta file was merged and conflicts occurred during merge
583 .It ! Ta changes destined for a missing file were not merged
584 .It D Ta file was deleted
585 .It d Ta file's deletion was obstructed by local modifications
586 .It A Ta new file was added
587 .It ~ Ta changes destined for a non-regular file were not merged
590 The reverse-merged changes will appear as local changes in the work tree,
591 which may be viewed with
593 amended manually or with further
598 or discarded again with
602 will refuse to run if certain preconditions are not met.
603 If the work tree contains multiple base commits it must first be updated
604 to a single base commit with
606 If the work tree already contains files with merge conflicts, these
607 conflicts must be resolved first.
611 .It Cm rebase [ Fl a ] [ Fl c] [ Ar branch ]
612 Rebase commits on the specified
614 onto the tip of the current branch of the work tree.
617 must share common ancestry with the work tree's current branch.
618 Rebasing begins with the first descendent commit of the youngest
619 common ancestor commit shared by the specified
621 and the work tree's current branch, and stops once the tip commit
626 Rebased commits are accumulated on a temporary branch and represent
627 the same changes with the same log messages as their counterparts
630 but with different commit IDs.
631 Once rebasing has completed successfully, the temporary branch becomes
632 the new version of the specified
634 and the work tree is automatically switched to it.
636 While rebasing commits, show the status of each affected file,
637 using the following status codes:
638 .Bl -column YXZ description
639 .It G Ta file was merged
640 .It C Ta file was merged and conflicts occurred during merge
641 .It ! Ta changes destined for a missing file were not merged
642 .It D Ta file was deleted
643 .It d Ta file's deletion was obstructed by local modifications
644 .It A Ta new file was added
645 .It ~ Ta changes destined for a non-regular file were not merged
648 If merge conflicts occur the rebase operation is interrupted and may
649 be continued once conflicts have been resolved.
650 Alternatively, the rebase operation may be aborted which will leave
652 unmodified and the work tree switched back to its original branch.
654 If a merge conflict is resolved in a way which renders the merged
655 change into a no-op change, the corresponding commit will be elided
656 when the rebase operation continues.
659 will refuse to run if certain preconditions are not met.
660 If the work tree contains multiple base commits it must first be updated
661 to a single base commit with
663 If the work tree contains local changes, these changes must first be
670 contains changes to files outside of the work tree's path prefix,
671 the work tree cannot be used to rebase this branch.
677 commands will refuse to run while a rebase operation is in progress.
678 Other commands which manipulate the work tree may be used for
679 conflict resolution purposes.
686 Abort an interrupted rebase operation.
687 If this option is used, no further command-line arguments are allowed.
689 Continue an interrupted rebase operation.
690 If this option is used, no further command-line arguments are allowed.
695 .It Cm histedit [ Fl a ] [ Fl c] [ Fl F Ar histedit-script ]
696 Edit commit history between the work tree's current base commit and
697 the tip commit of the work tree's current branch.
699 Editing of commit history is controlled via a
701 which can be edited interactively or passed on the command line.
702 The format of the histedit script is line-based.
703 Each line in the script begins with a command name, followed by
704 whitespace and an argument.
705 For most commands, the expected argument is a commit ID SHA1 hash.
706 Any remaining text on the line is ignored.
707 Lines which begin with the
709 character are ignored entirely.
711 The available commands are as follows:
712 .Bl -column YXZ pick-commit
713 .It pick Ar commit Ta Use the specified commit as it is.
714 .It edit Ar commit Ta Use the specified commit but once changes have been
715 merged into the work tree interrupt the histedit operation for amending.
716 .It fold Ar commit Ta Combine the specified commit with the next commit
717 listed further below that will be used.
718 .It drop Ar commit Ta Remove this commit from the edited history.
719 .It mesg Ar log-message Ta Use the specified single-line log message for
720 the commit on the previous line.
721 If the log message argument is left empty, open an editor where a new
722 log message can be written.
725 Every commit in the history being edited must be mentioned in the script.
726 Lines may be re-ordered to change the order of commits in the edited history.
728 Edited commits are accumulated on a temporary branch.
729 Once history editing has completed successfully, the temporary branch becomes
730 the new version of the work tree's branch and the work tree is automatically
733 While merging commits, show the status of each affected file,
734 using the following status codes:
735 .Bl -column YXZ description
736 .It G Ta file was merged
737 .It C Ta file was merged and conflicts occurred during merge
738 .It ! Ta changes destined for a missing file were not merged
739 .It D Ta file was deleted
740 .It d Ta file's deletion was obstructed by local modifications
741 .It A Ta new file was added
742 .It ~ Ta changes destined for a non-regular file were not merged
745 If merge conflicts occur the histedit operation is interrupted and may
746 be continued once conflicts have been resolved.
747 Alternatively, the histedit operation may be aborted which will leave
748 the work tree switched back to its original branch.
750 If a merge conflict is resolved in a way which renders the merged
751 change into a no-op change, the corresponding commit will be elided
752 when the histedit operation continues.
755 will refuse to run if certain preconditions are not met.
756 If the work tree contains multiple base commits it must first be updated
757 to a single base commit with
759 If the work tree contains local changes, these changes must first be
764 If the edited history contains changes to files outside of the work tree's
765 path prefix, the work tree cannot be used to edit the history of this branch.
769 command will refuse to run while a histedit operation is in progress.
770 Other commands which manipulate the work tree may be used, and the
772 command may be used to commit arbitrary changes to the temporary branch
773 while the histedit operation is interrupted.
780 Abort an interrupted histedit operation.
781 If this option is used, no further command-line arguments are allowed.
783 Continue an interrupted histedit operation.
784 If this option is used, no further command-line arguments are allowed.
791 .Bl -tag -width GOT_AUTHOR
793 The author's name and email address for
798 .An Stefan Sperling Aq Mt stsp@openbsd.org
799 .It Ev VISUAL, Ev EDITOR
800 The editor spawned by
806 Clone an existing Git repository for use with
808 This step currently requires
812 .Dl $ git clone --bare https://github.com/openbsd/src.git
814 Alternatively, for quick and dirty local testing of
816 a new Git repository could be created and populated with files,
817 e.g. from a temporary CVS checkout located at
820 .Dl $ got init /var/git/src.git
821 .Dl $ got import -r /var/git/src.git -I CVS -I obj /tmp/src
823 Check out a work tree from the Git repository to /usr/src:
825 .Dl $ got checkout /var/git/src.git /usr/src
827 View local changes in a work tree directory:
830 .Dl $ got diff | less
832 In a work tree or a git repository directory, list all branch references:
836 In a work tree or a git repository directory, create a new branch called
837 .Dq unified-buffer-cache
838 which is forked off the
842 .Dl $ got branch unified-buffer-cache master
844 Switch an existing work tree to the branch
845 .Dq unified-buffer-cache .
846 Local changes in the work tree will be preserved and merged if necessary:
848 .Dl $ got update -b unified-buffer-cache
850 Create a new commit from local changes in a work tree directory.
851 This new commit will become the head commit of the work tree's current branch:
855 In a work tree or a git repository directory, view changes committed in
856 the 3 most recent commits to the work tree's branch, or the branch resolved
857 via the repository's HEAD reference, respectively:
859 .Dl $ got log -p -l 3 -f
861 Add new files and remove obsolete files in a work tree directory:
863 .Dl $ got add sys/uvm/uvm_ubc.c
864 .Dl $ got remove sys/uvm/uvm_vnode.c
866 Create a new commit from local changes in a work tree directory
867 with a pre-defined log message.
869 .Dl $ got commit -m 'unify the buffer cache'
871 Update any work tree checked out from the
872 .Dq unified-buffer-cache
873 branch to the latest commit on this branch:
877 Roll file content on the unified-buffer-cache branch back by one commit,
878 and then fetch the rolled-back change into the work tree as a local change
879 to be amended and perhaps committed again:
881 .Dl $ got backout unified-buffer-cache
882 .Dl $ got commit -m 'roll back previous'
883 .Dl $ # now back out the previous backout :-)
884 .Dl $ got backout unified-buffer-cache
886 Fetch new upstream commits into the local repository's master branch.
887 This step currently requires
890 .Dl $ cd /var/git/src.git
891 .Dl $ git fetch origin master:master
894 .Dq unified-buffer-cache
895 branch on top of the new head commit of the
899 .Dl $ got update -b master
900 .Dl $ got rebase unified-buffer-cache
902 Create a patch from all changes on the unified-buffer-cache branch.
903 The patch can be mailed out for review and applied to OpenBSD's CVS tree:
905 .Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff
907 Edit the entire commit history of the
908 .Dq unified-buffer-cache
911 .Dl $ got update -b unified-buffer-cache
912 .Dl $ got update -c master
917 .Xr git-repository 5 ,
920 .An Stefan Sperling Aq Mt stsp@openbsd.org
921 .An Martin Pieuchot Aq Mt mpi@openbsd.org
922 .An joshua stein Aq Mt jcs@openbsd.org
925 is a work-in-progress and many commands remain to be implemented.
926 At present, the user has to fall back on
928 to perform tasks related to repository administration and tasks
929 which require a network connection.
931 When working against a repository created with
932 .Dq git clone --bare ,
935 branch are discouraged, for now, if changes committed to the upstream
936 repository need to be tracked.
937 See the EXAMPLES section.
942 commands should alleviate this problem.