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
66 .It Cm checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
67 Copy files from a repository into a new work tree.
70 is not specified, either use the last component of
74 was specified use the last component of
82 Check out files from the specified
84 If this option is not specified, a branch resolved via the repository's HEAD
85 reference will be used.
87 Check out files from the specified
89 The expected argument is a commit ID SHA1 hash.
90 An abbreviated hash argument will be expanded to a full SHA1 hash
91 automatically, provided the abbreviation is unique.
92 If this option is not specified, the most recent commit on the selected
94 .It Fl p Ar path-prefix
95 Restrict the work tree to a subset of the repository's tree hierarchy.
96 Only files beneath the specified
103 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
104 Update an existing work tree to a different commit.
105 Show the status of each affected file, using the following status codes:
106 .Bl -column YXZ description
107 .It U Ta file was updated and contained no local changes
108 .It G Ta file was updated and local changes were merged cleanly
109 .It C Ta file was updated and conflicts occurred during merge
110 .It D Ta file was deleted
111 .It A Ta new file was added
112 .It ~ Ta versioned file is obstructed by a non-regular file
113 .It ! Ta a missing versioned file was restored
118 is specified, restrict the update operation to files at or within this path.
119 The path is required to exist in the update operation's target commit.
120 Files in the work tree outside this path will remain unchanged and will
121 retain their previously recorded base commit.
124 commands may refuse to run while the work tree contains files from
125 multiple base commits.
126 The base commit of such a work tree can be made consistent by running
128 across the entire work tree.
131 is incompatible with the
140 Switch the work tree's branch reference to the specified
142 before updating the work tree.
143 This option requires that all paths in the work tree are updated.
145 Update the work tree to the specified
147 The expected argument is a commit ID SHA1 hash.
148 An abbreviated hash argument will be expanded to a full SHA1 hash
149 automatically, provided the abbreviation is unique.
150 If this option is not specified, the most recent commit on the work tree's
156 .It Cm status [ Ar path ]
157 Show the current modification status of files in a work tree,
158 using the following status codes:
159 .Bl -column YXZ description
160 .It M Ta modified file
161 .It A Ta file scheduled for addition in next commit
162 .It D Ta file scheduled for deletion in next commit
163 .It C Ta modified or added file which contains merge conflicts
164 .It ! Ta versioned file was expected on disk but is missing
165 .It ~ Ta versioned file is obstructed by a non-regular file
166 .It ? Ta unversioned item not tracked by
172 is specified, only show modifications within this path.
176 .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 ]
177 Display history of a repository.
180 is specified, show only commits which modified this path.
187 Show the linear line of history of the current branch.
188 This option restricts history traversal to the first parent of each commit.
189 Commits which the branch was based on and merge commits which affected the
190 branch will be shown, but individual commits created on parallel branches
193 Start traversing history at the specified
195 The expected argument is the name of a branch or a commit ID SHA1 hash.
196 An abbreviated hash argument will be expanded to a full SHA1 hash
197 automatically, provided the abbreviation is unique.
198 If this option is not specified, default to the work tree's current branch
199 if invoked in a work tree, or to the repository's HEAD reference.
201 Set the number of context lines shown in diffs with
203 By default, 3 lines of context are shown.
205 Limit history traversal to a given number of commits.
207 Display the patch of modifications made in each commit.
208 .It Fl r Ar repository-path
209 Use the repository at the specified path.
210 If not specified, assume the repository is located at or above the current
212 If this directory is a
214 work tree, use the repository path associated with this work tree.
216 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
217 When invoked within a work tree with less than two arguments, display
218 uncommitted changes in the work tree.
221 is specified, only show changes within this path.
223 If two arguments are provided, treat each argument as a reference,
224 or an object ID SHA1 hash, and display differences between these objects.
225 Both objects must be of the same type (blobs, trees, or commits).
226 An abbreviated hash argument will be expanded to a full SHA1 hash
227 automatically, provided the abbreviation is unique.
234 Set the number of context lines shown in the diff.
235 By default, 3 lines of context are shown.
236 .It Fl r Ar repository-path
237 Use the repository at the specified path.
238 If not specified, assume the repository is located at or above the current
240 If this directory is a
242 work tree, use the repository path associated with this work tree.
244 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
245 Display line-by-line history of a file at the specified path.
252 Start traversing history at the specified
254 The expected argument is the name of a branch or a commit ID SHA1 hash.
255 An abbreviated hash argument will be expanded to a full SHA1 hash
256 automatically, provided the abbreviation is unique.
257 .It Fl r Ar repository-path
258 Use the repository at the specified path.
259 If not specified, assume the repository is located at or above the current
261 If this directory is a
263 work tree, use the repository path associated with this work tree.
265 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
266 Display a listing of files and directories at the specified
267 directory path in the repository.
268 Entries shown in this listing may carry one of the following trailing
270 .Bl -column YXZ description
271 .It / Ta entry is a directory
272 .It * Ta entry is an executable file
277 is specified, list the repository path corresponding to the current
278 directory of the work tree, or the root directory of the repository
279 if there is no work tree.
286 List files and directories as they appear in the specified
288 The expected argument is the name of a branch or a commit ID SHA1 hash.
289 An abbreviated hash argument will be expanded to a full SHA1 hash
290 automatically, provided the abbreviation is unique.
291 .It Fl r Ar repository-path
292 Use the repository at the specified path.
293 If not specified, assume the repository is located at or above the current
295 If this directory is a
297 work tree, use the repository path associated with this work tree.
299 Show object IDs of files (blob objects) and directories (tree objects).
301 Recurse into sub-directories in the repository.
303 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
304 Manage references in a repository.
306 If no options are passed, expect two arguments and attempt to create,
307 or update, the reference with the given
309 and make it point at the given
311 The target may be an object ID SHA1 hash or an existing reference which
312 will be resolved to an object ID.
313 An abbreviated hash argument will be expanded to a full SHA1 hash
314 automatically, provided the abbreviation is unique.
320 .It Fl r Ar repository-path
321 Use the repository at the specified path.
322 If not specified, assume the repository is located at or above the current
324 If this directory is a
326 work tree, use the repository path associated with this work tree.
328 List all existing references in the repository.
330 Delete the reference with the specified name from the repository.
332 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
333 Manage branches in a repository.
335 Branches are managed via references which live in the
340 command operates on references in this namespace only.
342 If no options are passed, expect one or two arguments and attempt to create
343 a branch with the given
345 and make it point at the given
349 is specified, default to the work tree's current branch if invoked in a
350 work tree, or to the repository's HEAD reference.
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 List all existing branches in the repository.
366 If invoked in a work tree, the work tree's current branch is shown
367 with one the following annotations:
368 .Bl -column YXZ description
369 .It * Ta work tree's base commit matches the branch tip
370 .It ~ Ta work tree's base commit is out-of-date
373 Delete the branch with the specified name from the repository.
374 Only the branch reference is deleted.
375 Any commit, tree, and blob objects belonging to the branch
376 remain in the repository and may be removed separately with
382 .It Cm add Ar file-path ...
383 Schedule unversioned files in a work tree for addition to the
384 repository in the next commit.
385 .It Cm remove Ar file-path ...
386 Remove versioned files from a work tree and schedule them for deletion
387 from the repository in the next commit.
394 Perform the operation even if a file contains uncommitted modifications.
399 .It Cm revert Ar file-path ...
400 Revert any uncommited changes in files at the specified paths.
401 File contents will be overwritten with those contained in the
402 work tree's base commit. There is no way to bring discarded
406 If a file was added with
408 it will become an unversioned file again.
409 If a file was deleted with
415 .It Cm commit [ Fl m Ar message ] [ file-path ]
416 Create a new commit in the repository from local changes in a work tree
417 and use this commit as the new base commit for the work tree.
419 Show the status of each affected file, using the following status codes:
420 .Bl -column YXZ description
421 .It M Ta modified file
422 .It D Ta file was deleted
423 .It A Ta new file was added
426 Files without local changes will retain their previously recorded base
430 commands may refuse to run while the work tree contains files from
431 multiple base commits.
432 The base commit of such a work tree can be made consistent by running
434 across the entire work tree.
440 environment variable to be set.
447 Use the specified log message when creating the new commit.
452 opens a temporary file in an editor where a log message can be written.
457 .It Cm cherrypick Ar commit
458 Merge changes from a single
463 must be on a different branch than the work tree's base commit.
464 The expected argument is a reference or a commit ID SHA1 hash.
465 An abbreviated hash argument will be expanded to a full SHA1 hash
466 automatically, provided the abbreviation is unique.
468 Show the status of each affected file, using the following status codes:
469 .Bl -column YXZ description
470 .It G Ta file was merged
471 .It C Ta file was merged and conflicts occurred during merge
472 .It ! Ta changes destined for a missing file were not merged
473 .It D Ta file was deleted
474 .It d Ta file's deletion was obstructed by local modifications
475 .It A Ta new file was added
476 .It ~ Ta changes destined for a non-regular file were not merged
479 The merged changes will appear as local changes in the work tree, which
482 amended manually or with further
487 or discarded again with
491 will refuse to run if certain preconditions are not met.
492 If the work tree contains multiple base commits it must first be updated
493 to a single base commit with
495 If the work tree already contains files with merge conflicts, these
496 conflicts must be resolved first.
500 .It Cm backout Ar commit
501 Reverse-merge changes from a single
506 must be on the same branch as the work tree's base commit.
507 The expected argument is a reference or a commit ID SHA1 hash.
508 An abbreviated hash argument will be expanded to a full SHA1 hash
509 automatically, provided the abbreviation is unique.
511 Show the status of each affected file, using the following status codes:
512 .Bl -column YXZ description
513 .It G Ta file was merged
514 .It C Ta file was merged and conflicts occurred during merge
515 .It ! Ta changes destined for a missing file were not merged
516 .It D Ta file was deleted
517 .It d Ta file's deletion was obstructed by local modifications
518 .It A Ta new file was added
519 .It ~ Ta changes destined for a non-regular file were not merged
522 The reverse-merged changes will appear as local changes in the work tree,
523 which may be viewed with
525 amended manually or with further
530 or discarded again with
534 will refuse to run if certain preconditions are not met.
535 If the work tree contains multiple base commits it must first be updated
536 to a single base commit with
538 If the work tree already contains files with merge conflicts, these
539 conflicts must be resolved first.
543 .It Cm rebase Ar branch
544 Rebase commits on the specified
546 onto the tip of the current branch of the work tree.
549 must share common ancestry with the work tree's current branch.
550 Rebasing begins with the first descendent commit of the youngest
551 common ancestor commit shared by the specified
553 and the work tree's current branch, and stops once the tip commit
558 Rebased commits are accumulated on a temporary branch and represent
559 the same changes with the same log messages as their counterparts
562 but with different commit IDs.
563 Once rebasing has completed successfully, the temporary branch becomes
564 the new version of the specified
566 and the work tree is automatically switched to it.
568 While rebasing commits, show the status of each affected file,
569 using the following status codes:
570 .Bl -column YXZ description
571 .It G Ta file was merged
572 .It C Ta file was merged and conflicts occurred during merge
573 .It ! Ta changes destined for a missing file were not merged
574 .It D Ta file was deleted
575 .It d Ta file's deletion was obstructed by local modifications
576 .It A Ta new file was added
577 .It ~ Ta changes destined for a non-regular file were not merged
580 If merge conflicts occur the rebase operation is interrupted and may
581 be continued once conflicts have been resolved.
582 Alternatively, the rebase operation may be aborted which will leave
584 unmodified and the work tree switched back to its original branch.
586 If a merge conflict is resolved in a way which renders the merged
587 change into a no-op change, the corresponding commit will be elided
588 when the rebase operation continues.
591 will refuse to run if certain preconditions are not met.
592 If the work tree contains multiple base commits it must first be updated
593 to a single base commit with
595 If the work tree contains local changes, these changes must first be
602 contains changes to files outside of the work tree's path prefix,
603 the work tree cannot be used to rebase this branch.
609 commands will refuse to run while a rebase operation is in progress.
610 Other commands which manipulate the work tree may be used for
611 conflict resolution purposes.
618 Abort an interrupted rebase operation.
620 Continue an interrupted rebase operation.
627 .Bl -tag -width GOT_AUTHOR
629 The author's name and email address for
632 .An Stefan Sperling Aq Mt stsp@openbsd.org
633 .It Ev VISUAL, Ev EDITOR
634 The editor spawned by
641 Clone an existing Git repository for use with
643 This step currently requires
647 .Dl $ git clone --bare https://github.com/openbsd/src.git
649 Check out a work tree from this Git repository to /usr/src:
651 .Dl $ got checkout /var/git/src.git /usr/src
653 View local changes in a work tree directory:
656 .Dl $ got diff | less
658 In a work tree or a git repository directory, list all branch references:
662 In a work tree or a git repository directory, create a new branch called
663 .Dq unified-buffer-cache
664 which is forked off the
668 .Dl $ got branch unified-buffer-cache master
670 Switch an existing work tree to the branch
671 .Dq unified-buffer-cache .
672 Local changes in the work tree will be preserved and merged if necessary:
674 .Dl $ got update -b unified-buffer-cache
676 Create a new commit from local changes in a work tree directory.
677 This new commit will become the head commit of the work tree's current branch:
681 In a work tree or a git repository directory, view changes committed in
682 the 3 most recent commits to the work tree's branch, or the branch resolved
683 via the repository's HEAD reference, respectively:
685 .Dl $ got log -p -l 3 -b
687 Add new files and remove obsolete files in a work tree directory:
689 .Dl $ got add sys/uvm/uvm_ubc.c
690 .Dl $ got remove sys/uvm/uvm_vnode.c
692 Create a new commit from local changes in a work tree directory
693 with a pre-defined log message.
695 .Dl $ got commit -m 'unify the buffer cache'
697 Update any work tree checked out from the
698 .Dq unified-buffer-cache
699 branch to the latest commit on this branch:
703 Fetch new upstream commits into the local repository's master branch.
704 This step currently requires
707 .Dl $ cd /var/git/src.git
708 .Dl $ git fetch origin master:master
711 .Dq unified-buffer-cache
712 branch on top of the new head commit of the
716 .Dl $ got update -b master
717 .Dl $ got rebase unified-buffer-cache
722 .An Stefan Sperling Aq Mt stsp@openbsd.org
723 .An Martin Pieuchot Aq Mt mpi@openbsd.org
724 .An joshua stein Aq Mt jcs@openbsd.org
727 is a work-in-progress and many commands remain to be implemented.
728 At present, the user has to fall back on
730 to perform many basic tasks.
732 When working against a repository created with
733 .Dq git clone --bare ,
736 branch are discouraged, for now, if changes committed to the upstream
737 repository need to be tracked.
738 See the EXAMPLES section.