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
100 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
101 Update an existing work tree to a different commit.
102 Show the status of each affected file, using the following status codes:
103 .Bl -column YXZ description
104 .It U Ta file was updated and contained no local changes
105 .It G Ta file was updated and local changes were merged cleanly
106 .It C Ta file was updated and conflicts occurred during merge
107 .It D Ta file was deleted
108 .It A Ta new file was added
109 .It ~ Ta versioned file is obstructed by a non-regular file
110 .It ! Ta a missing versioned file was restored
115 is specified, restrict the update operation to files at or within this path.
116 The path is required to exist in the update operation's target commit.
117 Files in the work tree outside this path will remain unchanged and will
118 retain their previously recorded base commit.
121 commands may refuse to run while the work tree contains files from
122 multiple base commits.
123 The base commit of such a work tree can be made consistent by running
125 across the entire work tree.
128 is incompatible with the
137 Switch the work tree's branch reference to the specified
139 before updating the work tree.
140 This option requires that all paths in the work tree are updated.
142 Update the work tree to the specified
144 The expected argument is a commit ID SHA1 hash.
145 An abbreviated hash argument will be expanded to a full SHA1 hash
146 automatically, provided the abbreviation is unique.
147 If this option is not specified, the most recent commit on the work tree's
150 .It Cm status [ Ar path ]
151 Show the current modification status of files in a work tree,
152 using the following status codes:
153 .Bl -column YXZ description
154 .It M Ta modified file
155 .It A Ta file scheduled for addition in next commit
156 .It D Ta file scheduled for deletion in next commit
157 .It C Ta modified or added file which contains merge conflicts
158 .It ! Ta versioned file was expected on disk but is missing
159 .It ~ Ta versioned file is obstructed by a non-regular file
160 .It ? Ta unversioned item not tracked by
166 is specified, only show modifications within this path.
167 .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 ]
168 Display history of a repository.
171 is specified, show only commits which modified this path.
178 Show the linear line of history of the current branch.
179 This option restricts history traversal to the first parent of each commit.
180 Commits which the branch was based on and merge commits which affected the
181 branch will be shown, but individual commits created on parallel branches
184 Start traversing history at the specified
186 The expected argument is the name of a branch or a commit ID SHA1 hash.
187 An abbreviated hash argument will be expanded to a full SHA1 hash
188 automatically, provided the abbreviation is unique.
189 If this option is not specified, default to the work tree's current branch
190 if invoked in a work tree, or to the repository's HEAD reference.
192 Set the number of context lines shown in diffs with
194 By default, 3 lines of context are shown.
196 Limit history traversal to a given number of commits.
198 Display the patch of modifications made in each commit.
199 .It Fl r Ar repository-path
200 Use the repository at the specified path.
201 If not specified, assume the repository is located at or above the current
203 If this directory is a
205 work tree, use the repository path associated with this work tree.
207 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
208 When invoked within a work tree with less than two arguments, display
209 uncommitted changes in the work tree.
212 is specified, only show changes within this path.
214 If two arguments are provided, treat each argument as a reference,
215 or an object ID SHA1 hash, and display differences between these objects.
216 Both objects must be of the same type (blobs, trees, or commits).
217 An abbreviated hash argument will be expanded to a full SHA1 hash
218 automatically, provided the abbreviation is unique.
225 Set the number of context lines shown in the diff.
226 By default, 3 lines of context are shown.
227 .It Fl r Ar repository-path
228 Use the repository at the specified path.
229 If not specified, assume the repository is located at or above the current
231 If this directory is a
233 work tree, use the repository path associated with this work tree.
235 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
236 Display line-by-line history of a file at the specified path.
243 Start traversing history at the specified
245 The expected argument is the name of a branch or a commit ID SHA1 hash.
246 An abbreviated hash argument will be expanded to a full SHA1 hash
247 automatically, provided the abbreviation is unique.
248 .It Fl r Ar repository-path
249 Use the repository at the specified path.
250 If not specified, assume the repository is located at or above the current
252 If this directory is a
254 work tree, use the repository path associated with this work tree.
256 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
257 Display a listing of files and directories at the specified
258 directory path in the repository.
259 Entries shown in this listing may carry one of the following trailing
261 .Bl -column YXZ description
262 .It / Ta entry is a directory
263 .It * Ta entry is an executable file
268 is specified, list the repository path corresponding to the current
269 directory of the work tree, or the root directory of the repository
270 if there is no work tree.
277 List files and directories as they appear in the specified
279 The expected argument is the name of a branch or a commit ID SHA1 hash.
280 An abbreviated hash argument will be expanded to a full SHA1 hash
281 automatically, provided the abbreviation is unique.
282 .It Fl r Ar repository-path
283 Use the repository at the specified path.
284 If not specified, assume the repository is located at or above the current
286 If this directory is a
288 work tree, use the repository path associated with this work tree.
290 Show object IDs of files (blob objects) and directories (tree objects).
292 Recurse into sub-directories in the repository.
294 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
295 Manage references in a repository.
297 If no options are passed, expect two arguments and attempt to create,
298 or update, the reference with the given
300 and make it point at the given
302 The target may be an object ID SHA1 hash or an existing reference which
303 will be resolved to an object ID.
304 An abbreviated hash argument will be expanded to a full SHA1 hash
305 automatically, provided the abbreviation is unique.
311 .It Fl r Ar repository-path
312 Use the repository at the specified path.
313 If not specified, assume the repository is located at or above the current
315 If this directory is a
317 work tree, use the repository path associated with this work tree.
319 List all existing references in the repository.
321 Delete the reference with the specified name from the repository.
323 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
324 Manage branches in a repository.
326 Branches are managed via references which live in the
331 command operates on references in this namespace only.
333 If no options are passed, expect one or two arguments and attempt to create
334 a branch with the given
336 and make it point at the given
340 is specified, default to the work tree's current branch if invoked in a
341 work tree, or to the repository's HEAD reference.
347 .It Fl r Ar repository-path
348 Use the repository at the specified path.
349 If not specified, assume the repository is located at or above the current
351 If this directory is a
353 work tree, use the repository path associated with this work tree.
355 List all existing branches in the repository.
357 Delete the branch with the specified name from the repository.
359 .It Cm add Ar file-path ...
360 Schedule unversioned files in a work tree for addition to the
361 repository in the next commit.
362 .It Cm rm Ar file-path ...
363 Remove versioned files from a work tree and schedule them for deletion
364 from the repository in the next commit.
371 Perform the operation even if a file contains uncommitted modifications.
373 .It Cm revert Ar file-path ...
374 Revert any uncommited changes in files at the specified paths.
375 File contents will be overwritten with those contained in the
376 work tree's base commit. There is no way to bring discarded
380 If a file was added with
382 it will become an unversioned file again.
383 If a file was deleted with
386 .It Cm commit [ Fl m Ar message ] [ file-path ]
387 Create a new commit in the repository from local changes in a work tree
388 and use this commit as the new base commit for the work tree.
390 Show the status of each affected file, using the following status codes:
391 .Bl -column YXZ description
392 .It M Ta modified file
393 .It D Ta file was deleted
394 .It A Ta new file was added
397 Files without local changes will retain their previously recorded base
401 commands may refuse to run while the work tree contains files from
402 multiple base commits.
403 The base commit of such a work tree can be made consistent by running
405 across the entire work tree.
411 environment variable to be set.
418 Use the specified log message when creating the new commit.
423 opens a temporary file in an editor where a log message can be written.
425 .It Cm cherrypick Ar commit
426 Merge changes from a single
431 must be on a different branch than the work tree's base commit.
432 The expected argument is a reference or a commit ID SHA1 hash.
433 An abbreviated hash argument will be expanded to a full SHA1 hash
434 automatically, provided the abbreviation is unique.
436 Show the status of each affected file, using the following status codes:
437 .Bl -column YXZ description
438 .It G Ta file was merged
439 .It C Ta file was merged and conflicts occurred during merge
440 .It ! Ta changes destined for a missing file were not merged
441 .It D Ta file was deleted
442 .It d Ta file's deletion was obstructed by local modifications
443 .It A Ta new file was added
444 .It ~ Ta changes destined for a non-regular file were not merged
447 The merged changes will appear as local changes in the work tree, which
450 amended manually or with further
455 or discarded again with
459 will refuse to run if certain preconditions are not met.
460 If the work tree contains multiple base commits it must first be updated
461 to a single base commit with
463 If the work tree already contains files with merge conflicts, these
464 conflicts must be resolved first.
465 .It Cm backout Ar commit
466 Reverse-merge changes from a single
471 must be on the same branch as the work tree's base commit.
472 The expected argument is a reference or a commit ID SHA1 hash.
473 An abbreviated hash argument will be expanded to a full SHA1 hash
474 automatically, provided the abbreviation is unique.
476 Show the status of each affected file, using the following status codes:
477 .Bl -column YXZ description
478 .It G Ta file was merged
479 .It C Ta file was merged and conflicts occurred during merge
480 .It ! Ta changes destined for a missing file were not merged
481 .It D Ta file was deleted
482 .It d Ta file's deletion was obstructed by local modifications
483 .It A Ta new file was added
484 .It ~ Ta changes destined for a non-regular file were not merged
487 The reverse-merged changes will appear as local changes in the work tree,
488 which may be viewed with
490 amended manually or with further
495 or discarded again with
499 will refuse to run if certain preconditions are not met.
500 If the work tree contains multiple base commits it must first be updated
501 to a single base commit with
503 If the work tree already contains files with merge conflicts, these
504 conflicts must be resolved first.
507 .Bl -tag -width GOT_AUTHOR
509 The author's name and email address for
512 .An Stefan Sperling Aq Mt stsp@openbsd.org
513 .It Ev VISUAL, Ev EDITOR
514 The editor spawned by
521 Clone an existing Git repository for use with
523 This step currently requires
527 .Dl $ git clone --bare https://github.com/openbsd/src.git
529 Check out a work tree from this Git repository to /usr/src:
531 .Dl $ got checkout /var/git/src.git /usr/src
533 View local changes in a work tree directory:
536 .Dl $ got diff | less
538 In a work tree or a git repository directory, list all branch references:
542 In a work tree or a git repository directory, create a new branch called
543 .Dq unified-buffer-cache
544 which is forked off the
548 .Dl $ got branch unified-buffer-cache master
550 Switch an existing work tree to the branch
551 .Dq unified-buffer-cache .
552 Local changes in the work tree will be preserved and merged if necessary:
554 .Dl $ got update -b unified-buffer-cache
556 Create a new commit from local changes in a work tree directory.
557 This new commit will become the head commit of the work tree's current branch:
561 In a work tree or a git repository directory, view changes committed in
562 the 3 most recent commits to the work tree's branch, or the branch resolved
563 via the repository's HEAD reference, respectively:
565 .Dl $ got log -p -l 3 -b
567 Add new files and remove obsolete files in a work tree directory:
569 .Dl $ got add sys/uvm/uvm_ubc.c
570 .Dl $ got rm sys/uvm/uvm_vnode.c
572 Create a new commit from local changes in a work tree directory
573 with a pre-defined log message.
575 .Dl $ got commit -m 'unify the buffer cache'
577 Update any work tree checked out from the
578 .Dq unified-buffer-cache
579 branch to the latest commit on this branch:
583 Fetch new upstream commits into the local repository's master branch.
584 This step currently requires
587 .Dl $ cd /var/git/src.git
588 .Dl $ git fetch origin master:master
591 .Dq unified-buffer-cache
592 branch on top of the new head commit of the
595 This step currently requires
598 .Dl $ git clone /var/git/src.git ~/src-git-wt
599 .Dl $ cd ~/src-git-wt
600 .Dl $ git checkout unified-buffer-cache
601 .Dl $ git rebase master
604 Update the work tree to the newly rebased
605 .Dq unified-buffer-cache
608 .Dl $ got update -b unified-buffer-cache
613 .An Stefan Sperling Aq Mt stsp@openbsd.org
614 .An Martin Pieuchot Aq Mt mpi@openbsd.org
615 .An joshua stein Aq Mt jcs@openbsd.org
618 is a work-in-progress and many commands remain to be implemented.
619 At present, the user has to fall back on
621 to perform many basic tasks.
623 When working against a repository created with
624 .Dq git clone --bare ,
627 branch are discouraged, for now, if changes committed to the upstream
628 repository need to be tracked.
629 See the EXAMPLES section.