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 If this option is not specified, the most recent commit on the selected
91 .It Fl p Ar path-prefix
92 Restrict the work tree to a subset of the repository's tree hierarchy.
93 Only files beneath the specified
97 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
98 Update an existing work tree to a different commit.
99 Show the status of each affected file, using the following status codes:
100 .Bl -column YXZ description
101 .It U Ta file was updated and contained no local changes
102 .It G Ta file was updated and local changes were merged cleanly
103 .It C Ta file was updated and conflicts occurred during merge
104 .It D Ta file was deleted
105 .It A Ta new file was added
106 .It ~ Ta versioned file is obstructed by a non-regular file
107 .It ! Ta a missing versioned file was restored
112 is specified, restrict the update operation to files at or within this path.
113 The path is required to exist in the update operation's target commit.
114 Files in the work tree outside this path will remain unchanged and will
115 retain their previously recorded base commit.
118 commands may refuse to run while the work tree contains files from
119 multiple base commits.
120 The base commit of such a work tree can be made consistent by running
122 across the entire work tree.
125 is incompatible with the
134 Switch the work tree's branch reference to the specified
136 before updating the work tree.
137 This option requires that all paths in the work tree are updated.
139 Update the work tree to the specified
141 The expected argument is a SHA1 hash which corresponds to a commit object.
142 If this option is not specified, the most recent commit on the work tree's
145 .It Cm status [ Ar path ]
146 Show the current modification status of files in a work tree,
147 using the following status codes:
148 .Bl -column YXZ description
149 .It M Ta modified file
150 .It A Ta file scheduled for addition in next commit
151 .It D Ta file scheduled for deletion in next commit
152 .It C Ta modified or added file which contains merge conflicts
153 .It ! Ta versioned file was expected on disk but is missing
154 .It ~ Ta versioned file is obstructed by a non-regular file
155 .It ? Ta unversioned item not tracked by
161 is specified, only show modifications within this path.
162 .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 ]
163 Display history of a repository.
166 is specified, show only commits which modified this path.
173 Show the linear line of history of the current branch.
174 This option restricts history traversal to the first parent of each commit.
175 Commits which the branch was based on and merge commits which affected the
176 branch will be shown, but individual commits created on parallel branches
179 Start traversing history at the specified
181 The expected argument is the name of a branch or a SHA1 hash which corresponds
183 If this option is not specified, default to the work tree's current branch
184 if invoked in a work tree, or to the repository's HEAD reference.
186 Set the number of context lines shown in diffs with
188 By default, 3 lines of context are shown.
190 Limit history traversal to a given number of commits.
192 Display the patch of modifications made in each commit.
193 .It Fl r Ar repository-path
194 Use the repository at the specified path.
195 If not specified, assume the repository is located at or above the current
197 If this directory is a
199 work tree, use the repository path associated with this work tree.
201 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
202 When invoked within a work tree with less than two arguments, display
203 uncommitted changes in the work tree.
206 is specified, only show changes within this path.
208 If two arguments are provided, treat each argument as a reference,
209 or a SHA1 hash, which corresponds to an object in the repository,
210 and display differences between these objects.
211 Both objects must be of the same type (blobs, trees, or commits).
218 Set the number of context lines shown in the diff.
219 By default, 3 lines of context are shown.
220 .It Fl r Ar repository-path
221 Use the repository at the specified path.
222 If not specified, assume the repository is located at or above the current
224 If this directory is a
226 work tree, use the repository path associated with this work tree.
228 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
229 Display line-by-line history of a file at the specified path.
236 Start traversing history at the specified
238 The expected argument is the name of a branch or a SHA1 hash which corresponds
240 .It Fl r Ar repository-path
241 Use the repository at the specified path.
242 If not specified, assume the repository is located at or above the current
244 If this directory is a
246 work tree, use the repository path associated with this work tree.
248 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
249 Display a listing of files and directories at the specified
250 directory path in the repository.
251 Entries shown in this listing may carry one of the following trailing
253 .Bl -column YXZ description
254 .It / Ta entry is a directory
255 .It * Ta entry is an executable file
260 is specified, list the repository path corresponding to the current
261 directory of the work tree, or the root directory of the repository
262 if there is no work tree.
269 List files and directories as they appear in the specified
271 The expected argument is the name of a branch or a SHA1 hash which corresponds
273 .It Fl r Ar repository-path
274 Use the repository at the specified path.
275 If not specified, assume the repository is located at or above the current
277 If this directory is a
279 work tree, use the repository path associated with this work tree.
281 Show object IDs of files (blob objects) and directories (tree objects).
283 Recurse into sub-directories in the repository.
285 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
286 Manage references in a repository.
288 If no options are passed, expect two arguments and attempt to create,
289 or update, the reference with the given
291 and make it point at the given
293 The target may be a SHA1 hash which corresponds to an existing object ID
294 in the repository, or an existing reference which will be resolved to an
301 .It Fl r Ar repository-path
302 Use the repository at the specified path.
303 If not specified, assume the repository is located at or above the current
305 If this directory is a
307 work tree, use the repository path associated with this work tree.
309 List all existing references in the repository.
311 Delete the reference with the specified name from the repository.
313 .It Cm add Ar file-path ...
314 Schedule unversioned files in a work tree for addition to the
315 repository in the next commit.
316 .It Cm rm Ar file-path ...
317 Remove versioned files from a work tree and schedule them for deletion
318 from the repository in the next commit.
325 Perform the operation even if a file contains uncommitted modifications.
327 .It Cm revert Ar file-path ...
328 Revert any uncommited changes in files at the specified paths.
329 File contents will be overwritten with those contained in the
330 work tree's base commit. There is no way to bring discarded
334 If a file was added with
336 it will become an unversioned file again.
337 If a file was deleted with
340 .It Cm commit [ Fl m Ar msg ] [ file-path ]
341 Create a new commit in the repository from local changes in a work tree
342 and use this commit as the new base commit for the work tree.
344 Show the status of each affected file, using the following status codes:
345 .Bl -column YXZ description
346 .It M Ta modified file
347 .It D Ta file was deleted
348 .It A Ta new file was added
351 Files without local changes will retain their previously recorded base
355 commands may refuse to run while the work tree contains files from
356 multiple base commits.
357 The base commit of such a work tree can be made consistent by running
359 across the entire work tree.
365 environment variable to be set.
372 Use the specified log message when creating the new commit.
377 opens a temporary file in an editor where a log message can be written.
379 .It Cm cherrypick Ar commit
380 Merge changes from a single
385 must be on a different branch than the work tree's base commit.
386 The expected argument is a reference or a SHA1 hash which corresponds to
389 Show the status of each affected file, using the following status codes:
390 .Bl -column YXZ description
391 .It G Ta file was merged
392 .It C Ta file was merged and conflicts occurred during merge
393 .It ! Ta changes destined for a missing file were not merged
394 .It D Ta file was deleted
395 .It d Ta file's deletion was obstructed by local modifications
396 .It A Ta new file was added
397 .It ~ Ta changes destined for a non-regular file were not merged
400 The merged changes will appear as local changes in the work tree, which
403 amended manually or with further
408 or discarded again with
412 will refuse to run if certain preconditions are not met.
413 If the work tree contains multiple base commits it must first be updated
414 to a single base commit with
416 If the work tree already contains files with merge conflicts, these
417 conflicts must be resolved first.
418 .It Cm backout Ar commit
419 Reverse-merge changes from a single
424 must be on the same branch as the work tree's base commit.
425 The expected argument is a reference or a SHA1 hash which corresponds to
428 Show the status of each affected file, using the following status codes:
429 .Bl -column YXZ description
430 .It G Ta file was merged
431 .It C Ta file was merged and conflicts occurred during merge
432 .It ! Ta changes destined for a missing file were not merged
433 .It D Ta file was deleted
434 .It d Ta file's deletion was obstructed by local modifications
435 .It A Ta new file was added
436 .It ~ Ta changes destined for a non-regular file were not merged
439 The reverse-merged changes will appear as local changes in the work tree,
440 which may be viewed with
442 amended manually or with further
447 or discarded again with
451 will refuse to run if certain preconditions are not met.
452 If the work tree contains multiple base commits it must first be updated
453 to a single base commit with
455 If the work tree already contains files with merge conflicts, these
456 conflicts must be resolved first.
459 .Bl -tag -width GOT_AUTHOR
461 The author's name and email address for
464 .An Stefan Sperling Aq Mt stsp@openbsd.org
465 .It Ev VISUAL, Ev EDITOR
466 The editor spawned by
473 Clone an existing Git repository for use with
475 This step currently requires
479 .Dl $ git clone --bare https://github.com/openbsd/src.git
481 Check out a work tree from this Git repository to /usr/src:
483 .Dl $ got checkout /var/git/src.git /usr/src
485 View local changes in a work tree directory:
488 .Dl $ got diff | less
490 In a work tree or a git repository directory, list all branch references:
492 .Dl $ got ref -l | grep ^refs/heads
494 In a work tree or a git repository directory, create a new branch called
495 .Dq unified-buffer-cache
496 which is forked off the
500 .Dl $ got ref refs/heads/unified-buffer-cache refs/heads/master
502 Switch an existing work tree to the branch
503 .Dq unified-buffer-cache .
504 Local changes in the work tree will be preserved and merged if necessary:
506 .Dl $ got update -b unified-buffer-cache
508 Create a new commit from local changes in a work tree directory.
509 This new commit will become the head commit of the work tree's current branch:
513 In a work tree or a git repository directory, view changes committed in
514 the 3 most recent commits to the work tree's branch, or the branch resolved
515 via the repository's HEAD reference, respectively:
517 .Dl $ got log -p -l 3 -b
519 Add new files and remove obsolete files in a work tree directory:
521 .Dl $ got add sys/uvm/uvm_ubc.c
522 .Dl $ got rm sys/uvm/uvm_vnode.c
524 Create a new commit from local changes in a work tree directory
525 with a pre-defined log message.
527 .Dl $ got commit -m 'unify the buffer cache'
529 Update any work tree checked out from the
530 .Dq unified-buffer-cache
531 branch to the latest commit on this branch:
535 Fetch new upstream commits into the local repository's master branch:
537 .Dl $ cd /var/git/src.git
538 .Dl $ git fetch origin master:master
541 .Dq unified-buffer-cache
542 branch on top of the new head commit of the
545 This step currently requires
548 .Dl $ git clone /var/git/src.git ~/src-git-wt
549 .Dl $ cd ~/src-git-wt
550 .Dl $ git checkout unified-buffer-cache
551 .Dl $ git rebase master
554 Update the work tree to the newly rebased
555 .Dq unified-buffer-cache
558 .Dl $ got update -b unified-buffer-cache
563 .An Stefan Sperling Aq Mt stsp@openbsd.org
564 .An Martin Pieuchot Aq Mt mpi@openbsd.org
565 .An joshua stein Aq Mt jcs@openbsd.org
568 is a work-in-progress and many commands remain to be implemented.
569 At present, the user has to fall back on
571 to perform many basic tasks.
573 When working against a repository created with
574 .Dq git clone --bare ,
577 branch are discouraged, for now, if changes committed to the upstream
578 repository need to be tracked.
579 See the EXAMPLES section.