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
84 Show the path of each added file to indicate progress.
93 instead of creating the default branch
95 Use of this option is required if the
97 branch already exists.
99 Use the specified log message when creating the new commit.
104 opens a temporary file in an editor where a log message can be written.
105 .It Fl r Ar repository-path
106 Use the repository at the specified path.
107 If not specified, assume the repository is located at or above the current
110 Ignore files or directories with a name which matches the specified
112 This option may be specified multiple times to build a list of ignore patterns.
115 follows the globbing rules documented in
118 .It Cm checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
119 Copy files from a repository into a new work tree.
122 is not specified, either use the last component of
123 .Ar repository path ,
126 was specified use the last component of
134 Check out files from the specified
136 If this option is not specified, a branch resolved via the repository's HEAD
137 reference will be used.
139 Check out files from the specified
141 The expected argument is a commit ID SHA1 hash.
142 An abbreviated hash argument will be expanded to a full SHA1 hash
143 automatically, provided the abbreviation is unique.
144 If this option is not specified, the most recent commit on the selected
146 .It Fl p Ar path-prefix
147 Restrict the work tree to a subset of the repository's tree hierarchy.
148 Only files beneath the specified
155 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
156 Update an existing work tree to a different commit.
157 Show the status of each affected file, using the following status codes:
158 .Bl -column YXZ description
159 .It U Ta file was updated and contained no local changes
160 .It G Ta file was updated and local changes were merged cleanly
161 .It C Ta file was updated and conflicts occurred during merge
162 .It D Ta file was deleted
163 .It A Ta new file was added
164 .It ~ Ta versioned file is obstructed by a non-regular file
165 .It ! Ta a missing versioned file was restored
170 is specified, restrict the update operation to files at or within this path.
171 The path is required to exist in the update operation's target commit.
172 Files in the work tree outside this path will remain unchanged and will
173 retain their previously recorded base commit.
176 commands may refuse to run while the work tree contains files from
177 multiple base commits.
178 The base commit of such a work tree can be made consistent by running
180 across the entire work tree.
183 is incompatible with the
192 Switch the work tree's branch reference to the specified
194 before updating the work tree.
195 This option requires that all paths in the work tree are updated.
197 Update the work tree to the specified
199 The expected argument is a commit ID SHA1 hash.
200 An abbreviated hash argument will be expanded to a full SHA1 hash
201 automatically, provided the abbreviation is unique.
202 If this option is not specified, the most recent commit on the work tree's
208 .It Cm status [ Ar path ]
209 Show the current modification status of files in a work tree,
210 using the following status codes:
211 .Bl -column YXZ description
212 .It M Ta modified file
213 .It A Ta file scheduled for addition in next commit
214 .It D Ta file scheduled for deletion in next commit
215 .It C Ta modified or added file which contains merge conflicts
216 .It ! Ta versioned file was expected on disk but is missing
217 .It ~ Ta versioned file is obstructed by a non-regular file
218 .It ? Ta unversioned item not tracked by
224 is specified, only show modifications within this path.
228 .It Cm log [ Fl b ] [ Fl c Ar commit ] [ Fl C Ar number ] [ Fl l Ar N ] [ Fl p ] [ Fl r Ar repository-path ] [ path ]
229 Display history of a repository.
232 is specified, show only commits which modified this path.
239 Show the linear line of history of the current branch.
240 This option restricts history traversal to the first parent of each commit.
241 Commits which the branch was based on and merge commits which affected the
242 branch will be shown, but individual commits created on parallel branches
245 Start traversing history at the specified
247 The expected argument is the name of a branch or a commit ID SHA1 hash.
248 An abbreviated hash argument will be expanded to a full SHA1 hash
249 automatically, provided the abbreviation is unique.
250 If this option is not specified, default to the work tree's current branch
251 if invoked in a work tree, or to the repository's HEAD reference.
253 Set the number of context lines shown in diffs with
255 By default, 3 lines of context are shown.
257 Limit history traversal to a given number of commits.
259 Display the patch of modifications made in each commit.
260 .It Fl r Ar repository-path
261 Use the repository at the specified path.
262 If not specified, assume the repository is located at or above the current
264 If this directory is a
266 work tree, use the repository path associated with this work tree.
268 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
269 When invoked within a work tree with less than two arguments, display
270 uncommitted changes in the work tree.
273 is specified, only show changes within this path.
275 If two arguments are provided, treat each argument as a reference,
276 or an object ID SHA1 hash, and display differences between these objects.
277 Both objects must be of the same type (blobs, trees, or commits).
278 An abbreviated hash argument will be expanded to a full SHA1 hash
279 automatically, provided the abbreviation is unique.
286 Set the number of context lines shown in the diff.
287 By default, 3 lines of context are shown.
288 .It Fl r Ar repository-path
289 Use the repository at the specified path.
290 If not specified, assume the repository is located at or above the current
292 If this directory is a
294 work tree, use the repository path associated with this work tree.
296 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
297 Display line-by-line history of a file at the specified path.
304 Start traversing history at the specified
306 The expected argument is the name of a branch or a commit ID SHA1 hash.
307 An abbreviated hash argument will be expanded to a full SHA1 hash
308 automatically, provided the abbreviation is unique.
309 .It Fl r Ar repository-path
310 Use the repository at the specified path.
311 If not specified, assume the repository is located at or above the current
313 If this directory is a
315 work tree, use the repository path associated with this work tree.
317 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
318 Display a listing of files and directories at the specified
319 directory path in the repository.
320 Entries shown in this listing may carry one of the following trailing
322 .Bl -column YXZ description
323 .It / Ta entry is a directory
324 .It * Ta entry is an executable file
329 is specified, list the repository path corresponding to the current
330 directory of the work tree, or the root directory of the repository
331 if there is no work tree.
338 List files and directories as they appear in the specified
340 The expected argument is the name of a branch or a commit ID SHA1 hash.
341 An abbreviated hash argument will be expanded to a full SHA1 hash
342 automatically, provided the abbreviation is unique.
343 .It Fl r Ar repository-path
344 Use the repository at the specified path.
345 If not specified, assume the repository is located at or above the current
347 If this directory is a
349 work tree, use the repository path associated with this work tree.
351 Show object IDs of files (blob objects) and directories (tree objects).
353 Recurse into sub-directories in the repository.
355 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
356 Manage references in a repository.
358 If no options are passed, expect two arguments and attempt to create,
359 or update, the reference with the given
361 and make it point at the given
363 The target may be an object ID SHA1 hash or an existing reference which
364 will be resolved to an object ID.
365 An abbreviated hash argument will be expanded to a full SHA1 hash
366 automatically, provided the abbreviation is unique.
372 .It Fl r Ar repository-path
373 Use the repository at the specified path.
374 If not specified, assume the repository is located at or above the current
376 If this directory is a
378 work tree, use the repository path associated with this work tree.
380 List all existing references in the repository.
382 Delete the reference with the specified name from the repository.
384 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
385 Manage branches in a repository.
387 Branches are managed via references which live in the
392 command operates on references in this namespace only.
394 If no options are passed, expect one or two arguments and attempt to create
395 a branch with the given
397 and make it point at the given
401 is specified, default to the work tree's current branch if invoked in a
402 work tree, or to the repository's HEAD reference.
408 .It Fl r Ar repository-path
409 Use the repository at the specified path.
410 If not specified, assume the repository is located at or above the current
412 If this directory is a
414 work tree, use the repository path associated with this work tree.
416 List all existing branches in the repository.
418 If invoked in a work tree, the work tree's current branch is shown
419 with one the following annotations:
420 .Bl -column YXZ description
421 .It * Ta work tree's base commit matches the branch tip
422 .It ~ Ta work tree's base commit is out-of-date
425 Delete the branch with the specified name from the repository.
426 Only the branch reference is deleted.
427 Any commit, tree, and blob objects belonging to the branch
428 remain in the repository and may be removed separately with
429 Git's garbage collector.
434 .It Cm add Ar file-path ...
435 Schedule unversioned files in a work tree for addition to the
436 repository in the next commit.
437 .It Cm remove Ar file-path ...
438 Remove versioned files from a work tree and schedule them for deletion
439 from the repository in the next commit.
446 Perform the operation even if a file contains uncommitted modifications.
451 .It Cm revert Ar file-path ...
452 Revert any uncommited changes in files at the specified paths.
453 File contents will be overwritten with those contained in the
454 work tree's base commit. There is no way to bring discarded
458 If a file was added with
460 it will become an unversioned file again.
461 If a file was deleted with
467 .It Cm commit [ Fl m Ar message ] [ file-path ]
468 Create a new commit in the repository from local changes in a work tree
469 and use this commit as the new base commit for the work tree.
471 Show the status of each affected file, using the following status codes:
472 .Bl -column YXZ description
473 .It M Ta modified file
474 .It D Ta file was deleted
475 .It A Ta new file was added
478 Files without local changes will retain their previously recorded base
482 commands may refuse to run while the work tree contains files from
483 multiple base commits.
484 The base commit of such a work tree can be made consistent by running
486 across the entire work tree.
492 environment variable to be set.
499 Use the specified log message when creating the new commit.
504 opens a temporary file in an editor where a log message can be written.
509 .It Cm cherrypick Ar commit
510 Merge changes from a single
515 must be on a different branch than the work tree's base commit.
516 The expected argument is a reference or a commit ID SHA1 hash.
517 An abbreviated hash argument will be expanded to a full SHA1 hash
518 automatically, provided the abbreviation is unique.
520 Show the status of each affected file, using the following status codes:
521 .Bl -column YXZ description
522 .It G Ta file was merged
523 .It C Ta file was merged and conflicts occurred during merge
524 .It ! Ta changes destined for a missing file were not merged
525 .It D Ta file was deleted
526 .It d Ta file's deletion was obstructed by local modifications
527 .It A Ta new file was added
528 .It ~ Ta changes destined for a non-regular file were not merged
531 The merged changes will appear as local changes in the work tree, which
534 amended manually or with further
539 or discarded again with
543 will refuse to run if certain preconditions are not met.
544 If the work tree contains multiple base commits it must first be updated
545 to a single base commit with
547 If the work tree already contains files with merge conflicts, these
548 conflicts must be resolved first.
552 .It Cm backout Ar commit
553 Reverse-merge changes from a single
558 must be on the same branch as the work tree's base commit.
559 The expected argument is a reference or a commit ID SHA1 hash.
560 An abbreviated hash argument will be expanded to a full SHA1 hash
561 automatically, provided the abbreviation is unique.
563 Show the status of each affected file, using the following status codes:
564 .Bl -column YXZ description
565 .It G Ta file was merged
566 .It C Ta file was merged and conflicts occurred during merge
567 .It ! Ta changes destined for a missing file were not merged
568 .It D Ta file was deleted
569 .It d Ta file's deletion was obstructed by local modifications
570 .It A Ta new file was added
571 .It ~ Ta changes destined for a non-regular file were not merged
574 The reverse-merged changes will appear as local changes in the work tree,
575 which may be viewed with
577 amended manually or with further
582 or discarded again with
586 will refuse to run if certain preconditions are not met.
587 If the work tree contains multiple base commits it must first be updated
588 to a single base commit with
590 If the work tree already contains files with merge conflicts, these
591 conflicts must be resolved first.
595 .It Cm rebase [ Fl a ] [ Fl c] [ Ar branch ]
596 Rebase commits on the specified
598 onto the tip of the current branch of the work tree.
601 must share common ancestry with the work tree's current branch.
602 Rebasing begins with the first descendent commit of the youngest
603 common ancestor commit shared by the specified
605 and the work tree's current branch, and stops once the tip commit
610 Rebased commits are accumulated on a temporary branch and represent
611 the same changes with the same log messages as their counterparts
614 but with different commit IDs.
615 Once rebasing has completed successfully, the temporary branch becomes
616 the new version of the specified
618 and the work tree is automatically switched to it.
620 While rebasing commits, show the status of each affected file,
621 using the following status codes:
622 .Bl -column YXZ description
623 .It G Ta file was merged
624 .It C Ta file was merged and conflicts occurred during merge
625 .It ! Ta changes destined for a missing file were not merged
626 .It D Ta file was deleted
627 .It d Ta file's deletion was obstructed by local modifications
628 .It A Ta new file was added
629 .It ~ Ta changes destined for a non-regular file were not merged
632 If merge conflicts occur the rebase operation is interrupted and may
633 be continued once conflicts have been resolved.
634 Alternatively, the rebase operation may be aborted which will leave
636 unmodified and the work tree switched back to its original branch.
638 If a merge conflict is resolved in a way which renders the merged
639 change into a no-op change, the corresponding commit will be elided
640 when the rebase operation continues.
643 will refuse to run if certain preconditions are not met.
644 If the work tree contains multiple base commits it must first be updated
645 to a single base commit with
647 If the work tree contains local changes, these changes must first be
654 contains changes to files outside of the work tree's path prefix,
655 the work tree cannot be used to rebase this branch.
661 commands will refuse to run while a rebase operation is in progress.
662 Other commands which manipulate the work tree may be used for
663 conflict resolution purposes.
670 Abort an interrupted rebase operation.
671 If this option is used, no further command-line arguments are allowed.
673 Continue an interrupted rebase operation.
674 If this option is used, no further command-line arguments are allowed.
681 .Bl -tag -width GOT_AUTHOR
683 The author's name and email address for
686 .An Stefan Sperling Aq Mt stsp@openbsd.org
687 .It Ev VISUAL, Ev EDITOR
688 The editor spawned by
694 Clone an existing Git repository for use with
696 This step currently requires
700 .Dl $ git clone --bare https://github.com/openbsd/src.git
702 Alternatively, for quick and dirty local testing of
704 a new Git repository could be created and populated with files,
705 e.g. from a temporary CVS checkout located at
708 .Dl $ got init /var/git/src.git
709 .Dl $ got import -r /var/src.git -I CVS -I obj /tmp/src
711 Check out a work tree from the Git repository to /usr/src:
713 .Dl $ got checkout /var/git/src.git /usr/src
715 View local changes in a work tree directory:
718 .Dl $ got diff | less
720 In a work tree or a git repository directory, list all branch references:
724 In a work tree or a git repository directory, create a new branch called
725 .Dq unified-buffer-cache
726 which is forked off the
730 .Dl $ got branch unified-buffer-cache master
732 Switch an existing work tree to the branch
733 .Dq unified-buffer-cache .
734 Local changes in the work tree will be preserved and merged if necessary:
736 .Dl $ got update -b unified-buffer-cache
738 Create a new commit from local changes in a work tree directory.
739 This new commit will become the head commit of the work tree's current branch:
743 In a work tree or a git repository directory, view changes committed in
744 the 3 most recent commits to the work tree's branch, or the branch resolved
745 via the repository's HEAD reference, respectively:
747 .Dl $ got log -p -l 3 -b
749 Add new files and remove obsolete files in a work tree directory:
751 .Dl $ got add sys/uvm/uvm_ubc.c
752 .Dl $ got remove sys/uvm/uvm_vnode.c
754 Create a new commit from local changes in a work tree directory
755 with a pre-defined log message.
757 .Dl $ got commit -m 'unify the buffer cache'
759 Update any work tree checked out from the
760 .Dq unified-buffer-cache
761 branch to the latest commit on this branch:
765 Fetch new upstream commits into the local repository's master branch.
766 This step currently requires
769 .Dl $ cd /var/git/src.git
770 .Dl $ git fetch origin master:master
773 .Dq unified-buffer-cache
774 branch on top of the new head commit of the
778 .Dl $ got update -b master
779 .Dl $ got rebase unified-buffer-cache
781 Create a patch from all changes on the unified-buffer-cache branch.
782 The patch can be mailed out for review and applied to OpenBSD's CVS tree:
784 .Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff
790 .An Stefan Sperling Aq Mt stsp@openbsd.org
791 .An Martin Pieuchot Aq Mt mpi@openbsd.org
792 .An joshua stein Aq Mt jcs@openbsd.org
795 is a work-in-progress and many commands remain to be implemented.
796 At present, the user has to fall back on
798 to perform tasks related to repository administration and tasks
799 which require a network connection.
801 When working against a repository created with
802 .Dq git clone --bare ,
805 branch are discouraged, for now, if changes committed to the upstream
806 repository need to be tracked.
807 See the EXAMPLES section.
812 commands should alleviate this problem.