2 .\" Copyright (c) 2017 Martin Pieuchot
3 .\" Copyright (c) 2018, 2019, 2020 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 precede the command name, and are as follows:
54 .Bl -tag -width tenletters
56 Display usage information and exit immediately.
58 Display program version and exit immediately.
64 .Bl -tag -width checkout
65 .It Cm init Ar repository-path
66 Create a new empty repository at the specified
73 command must be used to populate the empty repository before
79 .It Cm import Oo Fl b Ar branch Oc Oo Fl m Ar message Oc Oo Fl r Ar repository-path Oc Oo Fl I Ar pattern Oc Ar directory
80 Create an initial commit in a repository from the file hierarchy
83 The created commit will not have any parent commits, i.e. it will be a
85 Also create a new reference which provides a branch name for the newly
87 Show the path of each imported file to indicate progress.
93 environment variable to be set,
98 configuration settings can be obtained from the repository's
100 file or from Git's global
111 instead of creating the default branch
113 Use of this option is required if the
115 branch already exists.
117 Use the specified log message when creating the new commit.
122 opens a temporary file in an editor where a log message can be written.
123 .It Fl r Ar repository-path
124 Use the repository at the specified path.
125 If not specified, assume the repository is located at or above the current
128 Ignore files or directories with a name which matches the specified
130 This option may be specified multiple times to build a list of ignore patterns.
133 follows the globbing rules documented in
139 .It Cm clone Oo Fl a Oc Oo Fl b Ar branch Oc Oo Fl l Oc Oo Fl m Oc Oo Fl q Oc Oo Fl v Oc Oo Fl R Ar reference Oc Ar repository-URL Op Ar directory
140 Clone a Git repository at the specified
146 is specified the directory name will be derived from the name of the
149 will refuse to run if the
155 specifies a protocol scheme, a server hostname, an optional port number
156 separated from the hostname by a colon, and a path to the repository on
158 .Lk scheme://hostname:port/path/to/repository
160 The following protocol schemes are supported:
161 .Bl -tag -width git+ssh
163 The Git protocol as implemented by the
166 Use of this protocol is discouraged since it supports neither authentication
169 The Git protocol wrapped in an authenticated and encrypted
172 With this protocol the hostname may contain an embedded username for
177 Short alias for git+ssh.
180 Objects in the cloned repository are stored in a pack file which is downloaded
182 This pack file will then be indexed to facilitate access to the objects stored
184 If any objects in the pack file are stored in deltified form, all deltas will
185 be fully resolved in order to compute the ID of such objects.
186 This can take some time.
187 More details about the pack file format are documented in
188 .Xr git-repository 5 .
191 creates a remote repository entry in the
193 file of the cloned repository to store the
205 Fetch all branches from the remote repository's
208 If this option is not specified, a branch resolved via the remote
209 repository's HEAD reference will be fetched.
210 Cannot be used together with the
216 from the remote repository's
219 This option may be specified multiple times to build a list of branches
221 If the branch corresponding to the remote repository's HEAD reference is not
222 in this list, the cloned repository's HEAD reference will be set to the first
223 branch which was fetched.
224 If this option is not specified, a branch resolved via the remote
225 repository's HEAD reference will be fetched.
226 Cannot be used together with the
230 List branches and tags available for fetching from the remote repository
231 and exit immediately.
232 Cannot be used together with any of the other options except
235 Create the cloned repository as a mirror of the original repository.
236 This is useful if the cloned repository will not be used to store
237 local changes as created by
242 file will be set up with the
244 option enabled, such that
248 will write incoming changes directly to local branches in the
250 reference namespace, rather than to branches in the
253 This avoids the usual requirement of having to run
257 in order to make incoming changes appear on local branches.
258 But maintaining local changes in the cloned repository becomes difficult
259 since local changes will be at risk of being discarded whenever incoming
262 Suppress progress reporting output.
263 The same option will be passed to
270 to print debugging messages to standard error output.
271 This option will be passed to
274 Multiple -v options increase the verbosity.
276 .It Fl R Ar reference
277 In addition to the branches and tags that will be fetched, fetch an arbitrary
279 from the remote repository's
282 This option may be specified multiple times to build a list of additional
286 may either be a path to a specific reference, or a reference namespace
287 which will cause all references in this namespace to be fetched.
289 Each reference will be mapped into the cloned repository's
291 namespace, unless the
293 option is used to mirror references directly into the cloned repository's
298 will refuse to fetch references from the remote repository's
307 .It Cm fetch Oo Fl a Oc Oo Fl b Ar branch Oc Oo Fl d Oc Oo Fl l Oc Oo Fl r Ar repository-path Oc Oo Fl t Oc Oo Fl q Oc Oo Fl v Oc Oo Fl R Ar reference Oc Op Ar remote-repository
308 Fetch new changes from a remote repository.
310 .Ar remote-repository
314 The remote repository's URL is obtained from the corresponding entry in the
316 file of the local repository, as created by
319 New changes will be stored in a separate pack file downloaded from the server.
320 Optionally, separate pack files stored in the repository can be combined with
323 By default, branch references in the
325 reference namespace will be updated to point at the newly fetched commits.
328 command can then be used to make new changes visible on local branches in the
330 namespace, merging incoming changes with local changes as necessary.
332 If the repository was created as a mirror with
334 then all branches in the
336 namespace will be updated directly to match the corresponding branches in
337 the remote repository.
338 If those branches contained local commits, these commits will no longer be
339 reachable via a reference and will therefore be at risk of being discarded
340 by Git's garbage collector.
341 Maintaining local changes in a mirror repository is therefore discouraged.
343 In any case, references in the
345 namespace will always be fetched and mapped directly to local references
346 in the same namespace.
353 Fetch all branches from the remote repository's
356 If this option is not specified, a branch resolved via the remote
357 repository's HEAD reference will be fetched.
358 Cannot be used together with the
364 from the remote repository's
367 This option may be specified multiple times to build a list of branches
369 If this option is not specified, a branch resolved via the remote
370 repository's HEAD reference will be fetched.
371 Cannot be used together with the
375 Delete branches and tags from the local repository which are no longer
376 present in the remote repository.
377 Only references are deleted.
378 Any commit, tree, tag, and blob objects belonging to deleted branches or
379 tags remain in the repository and may be removed separately with
380 Git's garbage collector.
382 List branches and tags available for fetching from the remote repository
383 and exit immediately.
384 Cannot be used together with any of the other options except
389 Allow existing references in the
391 namespace to be updated if they have changed on the server.
392 If not specified, only new tag references will be created.
393 .It Fl r Ar repository-path
394 Use the repository at the specified path.
395 If not specified, assume the repository is located at or above the current
397 If this directory is a
399 work tree, use the repository path associated with this work tree.
401 Suppress progress reporting output.
402 The same option will be passed to
409 to print debugging messages to standard error output.
410 The same option will be passed to
413 Multiple -v options increase the verbosity.
415 .It Fl R Ar reference
416 In addition to the branches and tags that will be fetched, fetch an arbitrary
418 from the remote repository's
421 This option may be specified multiple times to build a list of additional
425 may either be a path to a specific reference, or a reference namespace
426 which will cause all references in this namespace to be fetched.
428 Each reference will be mapped into the local repository's
430 namespace, unless the local repository was created as a mirror with
432 in which case references will be mapped directly into the local repository's
436 Once a reference has been fetched, a local branch based on it can be
442 will refuse to fetch references from the remote repository's
451 .It Cm checkout Oo Fl E Oc Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Oo Fl p Ar path-prefix Oc Ar repository-path Op Ar work-tree-path
452 Copy files from a repository into a new work tree.
453 Show the status of each affected file, using the following status codes:
454 .Bl -column YXZ description
455 .It A Ta new file was added
456 .It E Ta file already exists in work tree's meta-data
461 is not specified, either use the last component of
462 .Ar repository path ,
465 was specified use the last component of
473 Proceed with the checkout operation even if the directory at
476 Existing files will be left intact.
478 Check out files from a commit on the specified
480 If this option is not specified, a branch resolved via the repository's HEAD
481 reference will be used.
483 Check out files from the specified
485 on the selected branch.
486 The expected argument is a commit ID SHA1 hash or an existing reference
487 or tag name which will be resolved to a commit ID.
488 An abbreviated hash argument will be expanded to a full SHA1 hash
489 automatically, provided the abbreviation is unique.
490 If this option is not specified, the most recent commit on the selected
495 is not contained in the selected branch, a different branch which contains
496 this commit must be specified with the
499 If no such branch is known a new branch must be created for this
505 Checking out work trees with an unknown branch is intentionally not supported.
506 .It Fl p Ar path-prefix
507 Restrict the work tree to a subset of the repository's tree hierarchy.
508 Only files beneath the specified
515 .It Cm update Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Op Ar path ...
516 Update an existing work tree to a different commit.
517 Show the status of each affected file, using the following status codes:
518 .Bl -column YXZ description
519 .It U Ta file was updated and contained no local changes
520 .It G Ta file was updated and local changes were merged cleanly
521 .It C Ta file was updated and conflicts occurred during merge
522 .It D Ta file was deleted
523 .It A Ta new file was added
524 .It \(a~ Ta versioned file is obstructed by a non-regular file
525 .It ! Ta a missing versioned file was restored
530 is specified, update the entire work tree.
531 Otherwise, restrict the update operation to files at or within the
533 Each path is required to exist in the update operation's target commit.
534 Files in the work tree outside specified paths will remain unchanged and
535 will retain their previously recorded base commit.
538 commands may refuse to run while the work tree contains files from
539 multiple base commits.
540 The base commit of such a work tree can be made consistent by running
542 across the entire work tree.
545 is incompatible with the
550 cannot update paths with staged changes.
551 If changes have been staged with
553 these changes must first be committed with
563 Switch the work tree's branch reference to the specified
565 before updating the work tree.
566 This option requires that all paths in the work tree are updated.
568 Update the work tree to the specified
570 The expected argument is a commit ID SHA1 hash or an existing reference
571 or tag name which will be resolved to a commit ID.
572 An abbreviated hash argument will be expanded to a full SHA1 hash
573 automatically, provided the abbreviation is unique.
574 If this option is not specified, the most recent commit on the work tree's
580 .It Cm status Op Ar path ...
581 Show the current modification status of files in a work tree,
582 using the following status codes:
583 .Bl -column YXZ description
584 .It M Ta modified file
585 .It A Ta file scheduled for addition in next commit
586 .It D Ta file scheduled for deletion in next commit
587 .It C Ta modified or added file which contains merge conflicts
588 .It ! Ta versioned file was expected on disk but is missing
589 .It \(a~ Ta versioned file is obstructed by a non-regular file
590 .It ? Ta unversioned item not tracked by
592 .It m Ta modified file modes (executable bit only)
593 .It N Ta non-existent
595 specified on the command line
600 is specified, show modifications in the entire work tree.
601 Otherwise, show modifications at or within the specified paths.
603 If changes have been staged with
605 staged changes are shown in the second output column, using the following
607 .Bl -column YXZ description
608 .It M Ta file modification is staged
609 .It A Ta file addition is staged
610 .It D Ta file deletion is staged
613 Changes created on top of staged changes are indicated in the first column:
614 .Bl -column YXZ description
615 .It MM Ta file was modified after earlier changes have been staged
616 .It MA Ta file was modified after having been staged for addition
619 For compatibility with
630 files in each traversed directory and will not display unversioned files
631 which match these patterns.
636 supports consecutive asterisks,
638 which will match an arbitrary amount of directories.
642 only supports a single ignore pattern per line.
646 does not support negated ignore patterns prefixed with
648 and gives no special significance to the location of path component separators,
654 .It Cm log Oo Fl b Oc Oo Fl c Ar commit Oc Oo Fl C Ar number Oc Oo Fl l Ar N Oc Oo Fl p Oc Oo Fl s Ar search-pattern Oc Oo Fl r Ar repository-path Oc Op Ar path
655 Display history of a repository.
658 is specified, show only commits which modified this path.
659 If invoked in a work tree, the
661 is interpreted relative to the current working directory,
662 and the work tree's path prefix is implicitly prepended.
663 Otherwise, the path is interpreted relative to the repository root.
670 Display individual commits which were merged into the current branch
674 shows the linear history of the current branch only.
676 Start traversing history at the specified
678 The expected argument is a commit ID SHA1 hash or an existing reference
679 or tag name which will be resolved to a commit ID.
680 An abbreviated hash argument will be expanded to a full SHA1 hash
681 automatically, provided the abbreviation is unique.
682 If this option is not specified, default to the work tree's current branch
683 if invoked in a work tree, or to the repository's HEAD reference.
685 Set the number of context lines shown in diffs with
687 By default, 3 lines of context are shown.
689 Limit history traversal to a given number of commits.
690 If this option is not specified, a default limit value of zero is used,
691 which is treated as an unbounded limit.
693 .Ev GOT_LOG_DEFAULT_LIMIT
694 environment variable may be set to change this default value.
696 Display the patch of modifications made in each commit.
699 is specified, only show the patch of modifications at or within this path.
700 .It Fl s Ar search-pattern
701 If specified, show only commits with a log message matched by the extended
704 Regular expression syntax is documented in
706 .It Fl r Ar repository-path
707 Use the repository at the specified path.
708 If not specified, assume the repository is located at or above the current
710 If this directory is a
712 work tree, use the repository path associated with this work tree.
714 .It Cm diff Oo Fl C Ar number Oc Oo Fl r Ar repository-path Oc Oo Fl s Oc Oo Fl w Oc Op Ar object1 Ar object2 | Ar path
715 When invoked within a work tree with less than two arguments, display
716 uncommitted changes in the work tree.
719 is specified, only show changes within this path.
721 If two arguments are provided, treat each argument as a reference, a tag
722 name, or an object ID SHA1 hash, and display differences between the
723 corresponding objects.
724 Both objects must be of the same type (blobs, trees, or commits).
725 An abbreviated hash argument will be expanded to a full SHA1 hash
726 automatically, provided the abbreviation is unique.
733 Set the number of context lines shown in the diff.
734 By default, 3 lines of context are shown.
735 .It Fl r Ar repository-path
736 Use the repository at the specified path.
737 If not specified, assume the repository is located at or above the current
739 If this directory is a
741 work tree, use the repository path associated with this work tree.
743 Show changes staged with
745 instead of showing local changes.
746 This option is only valid when
748 is invoked in a work tree.
750 Ignore whitespace-only changes.
755 .It Cm blame Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Ar path
756 Display line-by-line history of a file at the specified path.
763 Start traversing history at the specified
765 The expected argument is a commit ID SHA1 hash or an existing reference
766 or tag name which will be resolved to a commit ID.
767 An abbreviated hash argument will be expanded to a full SHA1 hash
768 automatically, provided the abbreviation is unique.
769 .It Fl r Ar repository-path
770 Use the repository at the specified path.
771 If not specified, assume the repository is located at or above the current
773 If this directory is a
775 work tree, use the repository path associated with this work tree.
780 .It Cm tree Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Oo Fl i Oc Oo Fl R Oc Op Ar path
781 Display a listing of files and directories at the specified
782 directory path in the repository.
783 Entries shown in this listing may carry one of the following trailing
785 .Bl -column YXZ description
786 .It @ Ta entry is a symbolic link
787 .It / Ta entry is a directory
788 .It * Ta entry is an executable file
789 .It $ Ta entry is a Git submodule
794 is specified, list the repository path corresponding to the current
795 directory of the work tree, or the root directory of the repository
796 if there is no work tree.
803 List files and directories as they appear in the specified
805 The expected argument is a commit ID SHA1 hash or an existing reference
806 or tag name which will be resolved to a commit ID.
807 An abbreviated hash argument will be expanded to a full SHA1 hash
808 automatically, provided the abbreviation is unique.
809 .It Fl r Ar repository-path
810 Use the repository at the specified path.
811 If not specified, assume the repository is located at or above the current
813 If this directory is a
815 work tree, use the repository path associated with this work tree.
817 Show object IDs of files (blob objects) and directories (tree objects).
819 Recurse into sub-directories in the repository.
824 .It Cm ref Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl d Ar name Oc Oo Fl s Oc Op Ar name Ar target
825 Manage references in a repository.
827 If no options are passed, expect two arguments and attempt to create,
828 or update, the reference with the given
830 and make it point at the given
832 The name must be an absolute reference name, i.e. it must begin with
834 The target may be an object ID SHA1 hash or an existing reference which
835 will be resolved to an object ID.
836 An abbreviated hash argument will be expanded to a full SHA1 hash
837 automatically, provided the abbreviation is unique.
843 .It Fl r Ar repository-path
844 Use the repository at the specified path.
845 If not specified, assume the repository is located at or above the current
847 If this directory is a
849 work tree, use the repository path associated with this work tree.
851 List all existing references in the repository.
853 Delete the reference with the specified name from the repository.
855 Create a symbolic reference pointing at the specified
857 which must be an existing reference.
858 Care should be taken not to create loops between references when
861 .It Cm branch Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl d Ar name Oc Oo Fl n Oc Op Ar name
862 Create, list, or delete branches.
864 Branches are managed via references which live in the
869 command operates on references in this namespace only.
871 If invoked in a work tree without any arguments, print the name of the
872 work tree's current branch.
876 argument is passed, attempt to create a branch reference with the given name.
877 By default the new branch reference will point at the latest commit on the
878 work tree's current branch if invoked in a work tree, and otherwise to a commit
879 resolved via the repository's HEAD reference.
881 If invoked in a work tree, once the branch was created successfully
882 switch the work tree's head reference to the newly created branch and
883 update files across the entire work tree, just like
884 .Cm got update -b Ar name
886 Show the status of each affected file, using the following status codes:
887 .Bl -column YXZ description
888 .It U Ta file was updated and contained no local changes
889 .It G Ta file was updated and local changes were merged cleanly
890 .It C Ta file was updated and conflicts occurred during merge
891 .It D Ta file was deleted
892 .It A Ta new file was added
893 .It \(a~ Ta versioned file is obstructed by a non-regular file
894 .It ! Ta a missing versioned file was restored
902 Make a newly created branch reference point at the specified
906 argument is a commit ID SHA1 hash or an existing reference
907 or tag name which will be resolved to a commit ID.
908 .It Fl r Ar repository-path
909 Use the repository at the specified path.
910 If not specified, assume the repository is located at or above the current
912 If this directory is a
914 work tree, use the repository path associated with this work tree.
916 List all existing branches in the repository.
917 If invoked in a work tree, the work tree's current branch is shown
918 with one the following annotations:
919 .Bl -column YXZ description
920 .It * Ta work tree's base commit matches the branch tip
921 .It \(a~ Ta work tree's base commit is out-of-date
924 Delete the branch with the specified name from the repository.
925 Only the branch reference is deleted.
926 Any commit, tree, and blob objects belonging to the branch
927 remain in the repository and may be removed separately with
928 Git's garbage collector.
930 Do not switch and update the work tree after creating a new branch.
935 .It Cm tag Oo Fl c Ar commit Oc Oo Fl m Ar message Oc Oo Fl r Ar repository-path Oc Oo Fl l Oc Ar name
936 Manage tags in a repository.
938 Tags are managed via references which live in the
943 command operates on references in this namespace only.
944 References in this namespace point at tag objects which contain a pointer
945 to another object, a tag message, as well as author and timestamp information.
947 Attempt to create a tag with the given
949 and make this tag point at the given
951 If no commit is specified, default to the latest commit on the work tree's
952 current branch if invoked in a work tree, and to a commit resolved via
953 the repository's HEAD reference otherwise.
960 Make the newly created tag reference point at the specified
964 argument is a commit ID SHA1 hash or an existing reference or tag name which
965 will be resolved to a commit ID.
966 An abbreviated hash argument will be expanded to a full SHA1 hash
967 automatically, provided the abbreviation is unique.
969 Use the specified tag message when creating the new tag.
974 opens a temporary file in an editor where a tag message can be written.
975 .It Fl r Ar repository-path
976 Use the repository at the specified path.
977 If not specified, assume the repository is located at or above the current
979 If this directory is a
981 work tree, use the repository path associated with this work tree.
983 List all existing tags in the repository instead of creating a new tag.
984 If this option is used, no other command-line arguments are allowed.
989 command will not delete tags or change existing tags.
990 If a tag must be deleted, the
992 command may be used to delete a tag's reference.
993 This should only be done if the tag has not already been copied to
995 .It Cm add Oo Fl R Oc Oo Fl I Oc Ar path ...
996 Schedule unversioned files in a work tree for addition to the
997 repository in the next commit.
1004 Permit recursion into directories.
1005 If this option is not specified,
1007 will refuse to run if a specified
1011 With -R, add files even if they match a
1015 .It Cm remove Oo Fl f Oc Oo Fl k Oc Oo Fl R Oc Ar path ...
1016 Remove versioned files from a work tree and schedule them for deletion
1017 from the repository in the next commit.
1024 Perform the operation even if a file contains uncommitted modifications.
1026 Keep affected files on disk.
1028 Permit recursion into directories.
1029 If this option is not specified,
1031 will refuse to run if a specified
1038 .It Cm revert Oo Fl p Oc Oo Fl F Ar response-script Oc Oo Fl R Oc Ar path ...
1039 Revert any uncommitted changes in files at the specified paths.
1040 File contents will be overwritten with those contained in the
1041 work tree's base commit.
1042 There is no way to bring discarded changes back after
1045 If a file was added with
1047 it will become an unversioned file again.
1048 If a file was deleted with
1050 it will be restored.
1057 Instead of reverting all changes in files, interactively select or reject
1058 changes to revert based on
1064 (quit reverting this file) responses.
1065 If a file is in modified status, individual patches derived from the
1066 modified file content can be reverted.
1067 Files in added or deleted status may only be reverted in their entirety.
1068 .It Fl F Ar response-script
1076 responses line-by-line from the specified
1078 file instead of prompting interactively.
1080 Permit recursion into directories.
1081 If this option is not specified,
1083 will refuse to run if a specified
1090 .It Cm commit Oo Fl m Ar message Oc Op Ar path ...
1091 Create a new commit in the repository from changes in a work tree
1092 and use this commit as the new base commit for the work tree.
1095 is specified, commit all changes in the work tree.
1096 Otherwise, commit changes at or within the specified paths.
1098 If changes have been explicitly staged for commit with
1100 only commit staged changes and reject any specified paths which
1101 have not been staged.
1103 Show the status of each affected file, using the following status codes:
1104 .Bl -column YXZ description
1105 .It M Ta modified file
1106 .It D Ta file was deleted
1107 .It A Ta new file was added
1108 .It m Ta modified file modes (executable bit only)
1111 Files which are not part of the new commit will retain their previously
1112 recorded base commit.
1115 commands may refuse to run while the work tree contains files from
1116 multiple base commits.
1117 The base commit of such a work tree can be made consistent by running
1119 across the entire work tree.
1123 command requires the
1125 environment variable to be set,
1130 configuration settings can be
1131 obtained from the repository's
1133 file or from Git's global
1142 Use the specified log message when creating the new commit.
1147 opens a temporary file in an editor where a log message can be written.
1151 will refuse to run if certain preconditions are not met.
1152 If the work tree's current branch is not in the
1154 reference namespace, new commits may not be created on this branch.
1155 Local changes may only be committed if they are based on file content
1156 found in the most recent commit on the work tree's branch.
1157 If a path is found to be out of date,
1159 must be used first in order to merge local changes with changes made
1164 .It Cm cherrypick Ar commit
1165 Merge changes from a single
1170 must be on a different branch than the work tree's base commit.
1171 The expected argument is a reference or a commit ID SHA1 hash.
1172 An abbreviated hash argument will be expanded to a full SHA1 hash
1173 automatically, provided the abbreviation is unique.
1175 Show the status of each affected file, using the following status codes:
1176 .Bl -column YXZ description
1177 .It G Ta file was merged
1178 .It C Ta file was merged and conflicts occurred during merge
1179 .It ! Ta changes destined for a missing file were not merged
1180 .It D Ta file was deleted
1181 .It d Ta file's deletion was obstructed by local modifications
1182 .It A Ta new file was added
1183 .It \(a~ Ta changes destined for a non-regular file were not merged
1186 The merged changes will appear as local changes in the work tree, which
1189 amended manually or with further
1194 or discarded again with
1198 will refuse to run if certain preconditions are not met.
1199 If the work tree contains multiple base commits it must first be updated
1200 to a single base commit with
1202 If the work tree already contains files with merge conflicts, these
1203 conflicts must be resolved first.
1207 .It Cm backout Ar commit
1208 Reverse-merge changes from a single
1213 must be on the same branch as the work tree's base commit.
1214 The expected argument is a reference or a commit ID SHA1 hash.
1215 An abbreviated hash argument will be expanded to a full SHA1 hash
1216 automatically, provided the abbreviation is unique.
1218 Show the status of each affected file, using the following status codes:
1219 .Bl -column YXZ description
1220 .It G Ta file was merged
1221 .It C Ta file was merged and conflicts occurred during merge
1222 .It ! Ta changes destined for a missing file were not merged
1223 .It D Ta file was deleted
1224 .It d Ta file's deletion was obstructed by local modifications
1225 .It A Ta new file was added
1226 .It \(a~ Ta changes destined for a non-regular file were not merged
1229 The reverse-merged changes will appear as local changes in the work tree,
1230 which may be viewed with
1232 amended manually or with further
1237 or discarded again with
1241 will refuse to run if certain preconditions are not met.
1242 If the work tree contains multiple base commits it must first be updated
1243 to a single base commit with
1245 If the work tree already contains files with merge conflicts, these
1246 conflicts must be resolved first.
1250 .It Cm rebase Oo Fl a Oc Oo Fl c Oc Op Ar branch
1251 Rebase commits on the specified
1253 onto the tip of the current branch of the work tree.
1256 must share common ancestry with the work tree's current branch.
1257 Rebasing begins with the first descendant commit of the youngest
1258 common ancestor commit shared by the specified
1260 and the work tree's current branch, and stops once the tip commit
1267 is used as intended, the specified
1269 represents a local commit history and may already contain changes
1270 that are not yet visible in any other repositories.
1271 The work tree's current branch, which must be set with
1275 operation, represents a branch from a remote repository which shares
1276 a common history with the specified
1278 but has progressed, and perhaps diverged, due to commits added to the
1281 Rebased commits are accumulated on a temporary branch which the work tree
1282 will remain switched to throughout the entire rebase operation.
1283 Commits on this branch represent the same changes with the same log
1284 messages as their counterparts on the original
1286 but with different commit IDs.
1287 Once rebasing has completed successfully, the temporary branch becomes
1288 the new version of the specified
1290 and the work tree is automatically switched to it.
1292 While rebasing commits, show the status of each affected file,
1293 using the following status codes:
1294 .Bl -column YXZ description
1295 .It G Ta file was merged
1296 .It C Ta file was merged and conflicts occurred during merge
1297 .It ! Ta changes destined for a missing file were not merged
1298 .It D Ta file was deleted
1299 .It d Ta file's deletion was obstructed by local modifications
1300 .It A Ta new file was added
1301 .It \(a~ Ta changes destined for a non-regular file were not merged
1304 If merge conflicts occur the rebase operation is interrupted and may
1305 be continued once conflicts have been resolved.
1306 Alternatively, the rebase operation may be aborted which will leave
1308 unmodified and the work tree switched back to its original branch.
1310 If a merge conflict is resolved in a way which renders the merged
1311 change into a no-op change, the corresponding commit will be elided
1312 when the rebase operation continues.
1315 will refuse to run if certain preconditions are not met.
1316 If the work tree is not yet fully updated to the tip commit of its
1317 branch then the work tree must first be updated with
1319 If changes have been staged with
1321 these changes must first be committed with
1325 If the work tree contains local changes, these changes must first be
1332 contains changes to files outside of the work tree's path prefix,
1333 the work tree cannot be used to rebase this branch.
1339 commands will refuse to run while a rebase operation is in progress.
1340 Other commands which manipulate the work tree may be used for
1341 conflict resolution purposes.
1348 Abort an interrupted rebase operation.
1349 If this option is used, no other command-line arguments are allowed.
1351 Continue an interrupted rebase operation.
1352 If this option is used, no other command-line arguments are allowed.
1357 .It Cm histedit Oo Fl a Oc Oo Fl c Oc Oo Fl F Ar histedit-script Oc Oo Fl m Oc
1358 Edit commit history between the work tree's current base commit and
1359 the tip commit of the work tree's current branch.
1363 operation the work tree's current branch must be set with
1365 to the branch which should be edited, unless this branch is already the
1366 current branch of the work tree.
1367 The tip of this branch represents the upper bound (inclusive) of commits
1372 Furthermore, the work tree's base commit
1375 to a point in this branch's commit history where editing should begin.
1376 This commit represents the lower bound (non-inclusive) of commits touched
1381 Editing of commit history is controlled via a
1383 which can be written in an editor based on a template, passed on the
1384 command line, or generated with the
1386 option if only log messages need to be edited.
1388 The format of the histedit script is line-based.
1389 Each line in the script begins with a command name, followed by
1390 whitespace and an argument.
1391 For most commands, the expected argument is a commit ID SHA1 hash.
1392 Any remaining text on the line is ignored.
1393 Lines which begin with the
1395 character are ignored entirely.
1397 The available commands are as follows:
1398 .Bl -column YXZ pick-commit
1399 .It pick Ar commit Ta Use the specified commit as it is.
1400 .It edit Ar commit Ta Use the specified commit but once changes have been
1401 merged into the work tree interrupt the histedit operation for amending.
1402 .It fold Ar commit Ta Combine the specified commit with the next commit
1403 listed further below that will be used.
1404 .It drop Ar commit Ta Remove this commit from the edited history.
1405 .It mesg Ar log-message Ta Use the specified single-line log message for
1406 the commit on the previous line.
1407 If the log message argument is left empty, open an editor where a new
1408 log message can be written.
1411 Every commit in the history being edited must be mentioned in the script.
1412 Lines may be re-ordered to change the order of commits in the edited history.
1413 No commit may be listed more than once.
1415 Edited commits are accumulated on a temporary branch which the work tree
1416 will remain switched to throughout the entire histedit operation.
1417 Once history editing has completed successfully, the temporary branch becomes
1418 the new version of the work tree's branch and the work tree is automatically
1421 While merging commits, show the status of each affected file,
1422 using the following status codes:
1423 .Bl -column YXZ description
1424 .It G Ta file was merged
1425 .It C Ta file was merged and conflicts occurred during merge
1426 .It ! Ta changes destined for a missing file were not merged
1427 .It D Ta file was deleted
1428 .It d Ta file's deletion was obstructed by local modifications
1429 .It A Ta new file was added
1430 .It \(a~ Ta changes destined for a non-regular file were not merged
1433 If merge conflicts occur the histedit operation is interrupted and may
1434 be continued once conflicts have been resolved.
1435 Alternatively, the histedit operation may be aborted which will leave
1436 the work tree switched back to its original branch.
1438 If a merge conflict is resolved in a way which renders the merged
1439 change into a no-op change, the corresponding commit will be elided
1440 when the histedit operation continues.
1443 will refuse to run if certain preconditions are not met.
1444 If the work tree's current branch is not in the
1446 reference namespace, the history of the branch may not be edited.
1447 If the work tree contains multiple base commits it must first be updated
1448 to a single base commit with
1450 If changes have been staged with
1452 these changes must first be committed with
1456 If the work tree contains local changes, these changes must first be
1461 If the edited history contains changes to files outside of the work tree's
1462 path prefix, the work tree cannot be used to edit the history of this branch.
1469 commands will refuse to run while a histedit operation is in progress.
1470 Other commands which manipulate the work tree may be used, and the
1472 command may be used to commit arbitrary changes to the temporary branch
1473 while the histedit operation is interrupted.
1480 Abort an interrupted histedit operation.
1481 If this option is used, no other command-line arguments are allowed.
1483 Continue an interrupted histedit operation.
1484 If this option is used, no other command-line arguments are allowed.
1485 .It Fl F Ar histedit-script
1488 instead of opening a temporary file in an editor where a histedit script
1491 Edit log messages only.
1492 This option is a quick equivalent to a histedit script which edits
1493 only log messages but otherwise leaves every picked commit as-is.
1496 option can only be used when starting a new histedit operation.
1497 If this option is used, no other command-line arguments are allowed.
1502 .It Cm integrate Ar branch
1503 Integrate the specified
1505 into the work tree's current branch.
1506 Files in the work tree are updated to match the contents on the integrated
1508 and the reference of the work tree's branch is changed to point at the
1509 head commit of the integrated
1512 Both branches can be considered equivalent after integration since they
1513 will be pointing at the same commit.
1514 Both branches remain available for future work, if desired.
1515 In case the integrated
1517 is no longer needed it may be deleted with
1520 Show the status of each affected file, using the following status codes:
1521 .Bl -column YXZ description
1522 .It U Ta file was updated
1523 .It D Ta file was deleted
1524 .It A Ta new file was added
1525 .It \(a~ Ta versioned file is obstructed by a non-regular file
1526 .It ! Ta a missing versioned file was restored
1530 will refuse to run if certain preconditions are not met.
1531 Most importantly, the
1533 must have been rebased onto the work tree's current branch with
1535 before it can be integrated, in order to linearize commit history and
1536 resolve merge conflicts.
1537 If the work tree contains multiple base commits it must first be updated
1538 to a single base commit with
1540 If changes have been staged with
1542 these changes must first be committed with
1546 If the work tree contains local changes, these changes must first be
1554 .It Cm stage Oo Fl l Oc Oo Fl p Oc Oo Fl F Ar response-script Oc Op Ar path ...
1555 Stage local changes for inclusion in the next commit.
1558 is specified, stage all changes in the work tree.
1559 Otherwise, stage changes at or within the specified paths.
1560 Paths may be staged if they are added, modified, or deleted according to
1563 Show the status of each affected file, using the following status codes:
1564 .Bl -column YXZ description
1565 .It A Ta file addition has been staged
1566 .It M Ta file modification has been staged
1567 .It D Ta file deletion has been staged
1570 Staged file contents are saved in newly created blob objects in the repository.
1571 These blobs will be referred to by tree objects once staged changes have been
1574 Staged changes affect the behaviour of
1579 While paths with staged changes exist, the
1581 command will refuse to commit any paths which do not have staged changes.
1582 Local changes created on top of staged changes can only be committed if
1583 the path is staged again, or if the staged changes are committed first.
1586 command will show both local changes and staged changes.
1589 command is able to display local changes relative to staged changes,
1590 and to display staged changes relative to the repository.
1593 command cannot revert staged changes but may be used to revert
1594 local changes created on top of staged changes.
1601 Instead of staging new changes, list paths which are already staged,
1602 along with the IDs of staged blob objects and stage status codes.
1603 If paths were provided in the command line show the staged paths
1604 among the specified paths.
1605 Otherwise, show all staged paths.
1607 Instead of staging the entire content of a changed file, interactively
1608 select or reject changes for staging based on
1612 (reject change), and
1614 (quit staging this file) responses.
1615 If a file is in modified status, individual patches derived from the
1616 modified file content can be staged.
1617 Files in added or deleted status may only be staged or rejected in
1619 .It Fl F Ar response-script
1627 responses line-by-line from the specified
1629 file instead of prompting interactively.
1633 will refuse to run if certain preconditions are not met.
1634 If a file contains merge conflicts, these conflicts must be resolved first.
1635 If a file is found to be out of date relative to the head commit on the
1636 work tree's current branch, the file must be updated with
1638 before it can be staged (however, this does not prevent the file from
1639 becoming out-of-date at some point after having been staged).
1646 commands will refuse to run while staged changes exist.
1647 If staged changes cannot be committed because a staged path
1648 is out of date, the path must be unstaged with
1650 before it can be updated with
1652 and may then be staged again if necessary.
1656 .It Cm unstage Oo Fl p Oc Oo Fl F Ar response-script Oc Op Ar path ...
1657 Merge staged changes back into the work tree and put affected paths
1658 back into non-staged status.
1661 is specified, unstage all staged changes across the entire work tree.
1662 Otherwise, unstage changes at or within the specified paths.
1664 Show the status of each affected file, using the following status codes:
1665 .Bl -column YXZ description
1666 .It G Ta file was unstaged
1667 .It C Ta file was unstaged and conflicts occurred during merge
1668 .It ! Ta changes destined for a missing file were not merged
1669 .It D Ta file was staged as deleted and still is deleted
1670 .It d Ta file's deletion was obstructed by local modifications
1671 .It \(a~ Ta changes destined for a non-regular file were not merged
1679 Instead of unstaging the entire content of a changed file, interactively
1680 select or reject changes for unstaging based on
1684 (keep change staged), and
1686 (quit unstaging this file) responses.
1687 If a file is staged in modified status, individual patches derived from the
1688 staged file content can be unstaged.
1689 Files staged in added or deleted status may only be unstaged in their entirety.
1690 .It Fl F Ar response-script
1698 responses line-by-line from the specified
1700 file instead of prompting interactively.
1705 .It Cm cat Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Oo Fl P Oc Ar arg ...
1706 Parse and print contents of objects to standard output in a line-based
1708 Content of commit, tree, and tag objects is printed in a way similar
1709 to the actual content stored in such objects.
1710 Blob object contents are printed as they would appear in files on disk.
1712 Attempt to interpret each argument as a reference, a tag name, or
1713 an object ID SHA1 hash.
1714 References will be resolved to an object ID.
1715 Tag names will resolved to a tag object.
1716 An abbreviated hash argument will be expanded to a full SHA1 hash
1717 automatically, provided the abbreviation is unique.
1719 If none of the above interpretations produce a valid result, or if the
1721 option is used, attempt to interpret the argument as a path which will
1722 be resolved to the ID of an object found at this path in the repository.
1729 Look up paths in the specified
1731 If this option is not used, paths are looked up in the commit resolved
1732 via the repository's HEAD reference.
1733 The expected argument is a commit ID SHA1 hash or an existing reference
1734 or tag name which will be resolved to a commit ID.
1735 An abbreviated hash argument will be expanded to a full SHA1 hash
1736 automatically, provided the abbreviation is unique.
1737 .It Fl r Ar repository-path
1738 Use the repository at the specified path.
1739 If not specified, assume the repository is located at or above the current
1741 If this directory is a
1743 work tree, use the repository path associated with this work tree.
1745 Interpret all arguments as paths only.
1746 This option can be used to resolve ambiguity in cases where paths
1747 look like tag names, reference names, or object IDs.
1751 .Bl -tag -width GOT_AUTHOR
1753 The author's name and email address for
1758 .Dq An Flan Hacker Aq Mt flan_hacker@openbsd.org .
1761 may fail to parse commits without an email address in author data,
1765 environment variables with a missing email address.
1771 configuration settings in the repository's
1773 file will override the value of
1779 configuration settings contained in Git's global
1781 configuration file will be used only if the
1783 environment variable is
1786 .It Ev VISUAL , EDITOR
1787 The editor spawned by
1792 .It Ev GOT_LOG_DEFAULT_LIMIT
1793 The default limit on the number of commits traversed by
1795 If set to zero, the limit is unbounded.
1796 This variable will be silently ignored if it is set to a non-numeric value.
1801 Clone an existing Git repository for use with
1805 .Dl $ got clone ssh://git@github.com/openbsd/src.git
1807 Use of HTTP URLs currently requires
1811 .Dl $ git clone --bare https://github.com/openbsd/src.git
1813 Alternatively, for quick and dirty local testing of
1815 a new Git repository could be created and populated with files,
1816 e.g. from a temporary CVS checkout located at
1819 .Dl $ got init /var/git/src.git
1820 .Dl $ got import -r /var/git/src.git -I CVS -I obj /tmp/src
1822 Check out a work tree from the Git repository to /usr/src:
1824 .Dl $ got checkout /var/git/src.git /usr/src
1826 View local changes in a work tree directory:
1829 .Dl $ got diff | less
1831 Interactively revert selected local changes in a work tree directory:
1833 .Dl $ got revert -p -R\ .
1835 In a work tree or a git repository directory, list all branch references:
1839 In a work tree or a git repository directory, create a new branch called
1840 .Dq unified-buffer-cache
1841 which is forked off the
1845 .Dl $ got branch unified-buffer-cache master
1847 Switch an existing work tree to the branch
1848 .Dq unified-buffer-cache .
1849 Local changes in the work tree will be preserved and merged if necessary:
1851 .Dl $ got update -b unified-buffer-cache
1853 Create a new commit from local changes in a work tree directory.
1854 This new commit will become the head commit of the work tree's current branch:
1858 In a work tree or a git repository directory, view changes committed in
1859 the 3 most recent commits to the work tree's branch, or the branch resolved
1860 via the repository's HEAD reference, respectively:
1862 .Dl $ got log -p -l 3
1864 In a work tree or a git repository directory, log the history of a subdirectory:
1866 .Dl $ got log sys/uvm
1868 While operating inside a work tree, paths are specified relative to the current
1869 working directory, so this command will log the subdirectory
1872 .Dl $ cd sys/uvm && got log '.'
1874 And this command has the same effect:
1876 .Dl $ cd sys/dev/usb && got log ../../uvm
1878 Add new files and remove obsolete files in a work tree directory:
1880 .Dl $ got add sys/uvm/uvm_ubc.c
1881 .Dl $ got remove sys/uvm/uvm_vnode.c
1883 Create a new commit from local changes in a work tree directory
1884 with a pre-defined log message.
1886 .Dl $ got commit -m 'unify the buffer cache'
1888 Update any work tree checked out from the
1889 .Dq unified-buffer-cache
1890 branch to the latest commit on this branch:
1894 Roll file content on the unified-buffer-cache branch back by one commit,
1895 and then fetch the rolled-back change into the work tree as a local change
1896 to be amended and perhaps committed again:
1898 .Dl $ got backout unified-buffer-cache
1899 .Dl $ got commit -m 'roll back previous'
1900 .Dl $ # now back out the previous backout :-)
1901 .Dl $ got backout unified-buffer-cache
1903 Fetch new upstream commits into the local repository's
1910 In a repository created with a HTTP URL and
1911 .Cm git clone --bare
1914 command must be used instead:
1916 .Dl $ cd /var/git/src.git
1917 .Dl $ git fetch origin master:refs/remotes/origin/master
1921 branch to merge the new changes that are now visible on the
1926 .Dl $ got update -b origin/master
1927 .Dl $ got rebase master
1930 .Dq unified-buffer-cache
1931 branch on top of the new head commit of the
1935 .Dl $ got update -b master
1936 .Dl $ got rebase unified-buffer-cache
1938 Create a patch from all changes on the unified-buffer-cache branch.
1939 The patch can be mailed out for review and applied to
1943 .Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff
1945 Edit the entire commit history of the
1946 .Dq unified-buffer-cache
1949 .Dl $ got update -b unified-buffer-cache
1950 .Dl $ got update -c master
1953 In order to merge changes committed to the
1954 .Dq unified-buffer-cache
1955 branch back into the
1958 .Dq unified-buffer-cache
1959 branch must first be rebased onto the
1963 .Dl $ got update -b master
1964 .Dl $ got rebase unified-buffer-cache
1967 .Dq unified-buffer-cache
1968 branch can now be made visible on the
1972 Because the rebase operation switched the work tree to the
1973 .Dq unified-buffer-cache
1974 branch, the work tree must be switched back to the
1977 .Dq unified-buffer-cache
1978 branch can be integrated into
1981 .Dl $ got update -b master
1982 .Dl $ got integrate unified-buffer-cache
1984 Additional steps may be necessary if local changes need to be pushed back
1985 to the remote repository, which currently requires
1987 Before working against existing branches in a repository cloned with
1988 .Cm git clone --bare
1993 must be configured to map all references in the remote repository
1996 namespace of the local repository.
1997 This can achieved by setting Git's
1998 .Pa remote.origin.fetch
1999 configuration variable to the value
2000 .Dq +refs/heads/*:refs/remotes/origin/*
2005 .Dl $ cd /var/git/repo
2006 .Dl $ git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
2009 option must be disabled:
2011 .Dl $ cd /var/git/repo
2012 .Dl $ git config remote.origin.mirror false
2014 Alternatively, the following
2016 configuration item can be added manually to the Git repository's
2020 .Dl [remote "origin"]
2022 .Dl fetch = +refs/heads/*:refs/remotes/origin/*
2025 This configuration leaves the local repository's
2027 namespace free for use by local branches checked out with
2029 and, if needed, created with
2034 namespace can now be updated with incoming changes from the remote
2039 without extra command line arguments:
2041 .Dl $ cd /var/git/repo
2044 To make changes fetched from the remote repository appear on the
2048 branch must be rebased onto the
2051 This will also merge local changes, if any, with the incoming changes:
2053 .Dl $ got update -b origin/master
2054 .Dl $ got rebase master
2058 branch, log messages for local changes can now be amended with
2060 by other developers and any other important new information:
2062 .Dl $ got update -c origin/master
2063 .Dl $ got histedit -m
2065 Local changes on the
2067 branch can then be pushed to the remote
2071 .Dl $ cd /var/git/repo
2072 .Dl $ git push origin master
2075 .Xr git-repository 5 ,
2078 .An Stefan Sperling Aq Mt stsp@openbsd.org
2079 .An Martin Pieuchot Aq Mt mpi@openbsd.org
2080 .An Joshua Stein Aq Mt jcs@openbsd.org
2081 .An Ori Bernstein Aq Mt ori@openbsd.org
2084 is a work-in-progress and many commands remain to be implemented.
2085 At present, the user has to fall back on
2087 to perform many tasks, in particular tasks related to repository
2088 administration and tasks which require a network connection.