Blob


1 .\"
2 .\" Copyright (c) 2017 Martin Pieuchot
3 .\" Copyright (c) 2018, 2019 Stefan Sperling
4 .\"
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.
8 .\"
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.
16 .\"
17 .Dd $Mdocdate$
18 .Dt GOT 1
19 .Os
20 .Sh NAME
21 .Nm got
22 .Nd game of trees
23 .Sh SYNOPSIS
24 .Nm
25 .Ar command
26 .Op Fl h
27 .Op Ar arg ...
28 .Sh DESCRIPTION
29 .Nm
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 .
34 .Pp
35 .Nm
36 is a
37 .Dq distributed
38 version control system because every copy of a repository is writeable.
39 Modifications made to files can be synchronized between repositories
40 at any time.
41 .Pp
42 Files managed by
43 .Nm
44 must be checked out from the repository for modification.
45 Checked out files are stored in a
46 .Em work tree
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
49 .Xr got-worktree 5 .
50 .Pp
51 .Nm
52 provides global and command-specific options.
53 Global options must preceed the command name, and are as follows:
54 .Bl -tag -width tenletters
55 .It Fl h
56 Display usage information.
57 .El
58 .Pp
59 The commands for
60 .Nm
61 are as follows:
62 .Bl -tag -width checkout
63 .It Cm init Ar path
64 Create a new empty repository at the specified
65 .Ar path .
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.
68 If the
69 .Ar work tree path
70 is not specified, either use the last component of
71 .Ar repository path ,
72 or if a
73 .Ar path prefix
74 was specified use the last component of
75 .Ar path prefix .
76 .Pp
77 The options for
78 .Cm got checkout
79 are as follows:
80 .Bl -tag -width Ds
81 .It Fl b Ar branch
82 Check out files from the specified
83 .Ar branch .
84 If this option is not specified, a branch resolved via the repository's HEAD
85 reference will be used.
86 .It Fl c Ar commit
87 Check out files from the specified
88 .Ar commit .
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
93 branch will be used.
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
97 .Ar path-prefix
98 will be checked out.
99 .El
100 .It Cm co
101 Short alias for
102 .Cm checkout .
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
114 .El
115 .Pp
116 If a
117 .Ar path
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.
122 Some
123 .Nm
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
127 .Cm got update
128 across the entire work tree.
129 Specifying a
130 .Ar path
131 is incompatible with the
132 .Fl b
133 option.
134 .Pp
135 The options for
136 .Cm got update
137 are as follows:
138 .Bl -tag -width Ds
139 .It Fl b Ar branch
140 Switch the work tree's branch reference to the specified
141 .Ar branch
142 before updating the work tree.
143 This option requires that all paths in the work tree are updated.
144 .It Fl c Ar commit
145 Update the work tree to the specified
146 .Ar commit .
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
151 branch will be used.
152 .El
153 .It Cm up
154 Short alias for
155 .Cm update .
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
167 .Nm
168 .El
169 .Pp
170 If a
171 .Ar path
172 is specified, only show modifications within this path.
173 .It Cm st
174 Short alias for
175 .Cm status .
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.
178 If a
179 .Ar path
180 is specified, show only commits which modified this path.
181 .Pp
182 The options for
183 .Cm got log
184 are as follows:
185 .Bl -tag -width Ds
186 .It Fl b
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
191 will be omitted.
192 .It Fl c Ar commit
193 Start traversing history at the specified
194 .Ar commit .
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.
200 .It Fl C Ar number
201 Set the number of context lines shown in diffs with
202 .Fl p .
203 By default, 3 lines of context are shown.
204 .It Fl l Ar N
205 Limit history traversal to a given number of commits.
206 .It Fl p
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
211 working directory.
212 If this directory is a
213 .Nm
214 work tree, use the repository path associated with this work tree.
215 .El
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.
219 If a
220 .Ar path
221 is specified, only show changes within this path.
222 .Pp
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.
228 .Pp
229 The options for
230 .Cm got diff
231 are as follows:
232 .Bl -tag -width Ds
233 .It Fl C Ar number
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
239 working directory.
240 If this directory is a
241 .Nm
242 work tree, use the repository path associated with this work tree.
243 .El
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.
246 .Pp
247 The options for
248 .Cm got blame
249 are as follows:
250 .Bl -tag -width Ds
251 .It Fl c Ar commit
252 Start traversing history at the specified
253 .Ar commit .
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
260 working directory.
261 If this directory is a
262 .Nm
263 work tree, use the repository path associated with this work tree.
264 .El
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
269 annotations:
270 .Bl -column YXZ description
271 .It / Ta entry is a directory
272 .It * Ta entry is an executable file
273 .El
274 .Pp
275 If no
276 .Ar path
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.
280 .Pp
281 The options for
282 .Cm got tree
283 are as follows:
284 .Bl -tag -width Ds
285 .It Fl c Ar commit
286 List files and directories as they appear in the specified
287 .Ar commit .
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
294 working directory.
295 If this directory is a
296 .Nm
297 work tree, use the repository path associated with this work tree.
298 .It Fl i
299 Show object IDs of files (blob objects) and directories (tree objects).
300 .It Fl R
301 Recurse into sub-directories in the repository.
302 .El
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.
305 .Pp
306 If no options are passed, expect two arguments and attempt to create,
307 or update, the reference with the given
308 .Ar name ,
309 and make it point at the given
310 .Ar target .
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.
315 .Pp
316 The options for
317 .Cm got ref
318 are as follows:
319 .Bl -tag -width Ds
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
323 working directory.
324 If this directory is a
325 .Nm
326 work tree, use the repository path associated with this work tree.
327 .It Fl l
328 List all existing references in the repository.
329 .It Fl d Ar name
330 Delete the reference with the specified name from the repository.
331 .El
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.
334 .Pp
335 Branches are managed via references which live in the
336 .Dq refs/heads/
337 reference namespace.
338 The
339 .Cm got branch
340 command operates on references in this namespace only.
341 .Pp
342 If no options are passed, expect one or two arguments and attempt to create
343 a branch with the given
344 .Ar name ,
345 and make it point at the given
346 .Ar base-branch .
347 If no
348 .Ar base-branch
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.
351 .Pp
352 The options for
353 .Cm got branch
354 are as follows:
355 .Bl -tag -width Ds
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
359 working directory.
360 If this directory is a
361 .Nm
362 work tree, use the repository path associated with this work tree.
363 .It Fl l
364 List all existing branches in the repository.
365 .It Fl d Ar name
366 Delete the branch with the specified name from the repository.
367 .El
368 .It Cm br
369 Short alias for
370 .Cm branch .
371 .It Cm add Ar file-path ...
372 Schedule unversioned files in a work tree for addition to the
373 repository in the next commit.
374 .It Cm rm Ar file-path ...
375 Remove versioned files from a work tree and schedule them for deletion
376 from the repository in the next commit.
377 .Pp
378 The options for
379 .Cm got rm
380 are as follows:
381 .Bl -tag -width Ds
382 .It Fl f
383 Perform the operation even if a file contains uncommitted modifications.
384 .El
385 .It Cm revert Ar file-path ...
386 Revert any uncommited changes in files at the specified paths.
387 File contents will be overwritten with those contained in the
388 work tree's base commit. There is no way to bring discarded
389 changes back after
390 .Cm got revert !
391 .Pp
392 If a file was added with
393 .Cm got add
394 it will become an unversioned file again.
395 If a file was deleted with
396 .Cm got rm
397 it will be restored.
398 .It Cm rv
399 Short alias for
400 .Cm revert .
401 .It Cm commit [ Fl m Ar message ] [ file-path ]
402 Create a new commit in the repository from local changes in a work tree
403 and use this commit as the new base commit for the work tree.
404 .Pp
405 Show the status of each affected file, using the following status codes:
406 .Bl -column YXZ description
407 .It M Ta modified file
408 .It D Ta file was deleted
409 .It A Ta new file was added
410 .El
411 .Pp
412 Files without local changes will retain their previously recorded base
413 commit.
414 Some
415 .Nm
416 commands may refuse to run while the work tree contains files from
417 multiple base commits.
418 The base commit of such a work tree can be made consistent by running
419 .Cm got update
420 across the entire work tree.
421 .Pp
422 The
423 .Cm got commit
424 command requires the
425 .Ev GOT_AUTHOR
426 environment variable to be set.
427 .Pp
428 The options for
429 .Cm got commit
430 are as follows:
431 .Bl -tag -width Ds
432 .It Fl m Ar message
433 Use the specified log message when creating the new commit.
434 Without the
435 .Fl m
436 option,
437 .Cm got commit
438 opens a temporary file in an editor where a log message can be written.
439 .El
440 .It Cm ci
441 Short alias for
442 .Cm commit .
443 .It Cm cherrypick Ar commit
444 Merge changes from a single
445 .Ar commit
446 into the work tree.
447 The specified
448 .Ar commit
449 must be on a different branch than the work tree's base commit.
450 The expected argument is a reference or a commit ID SHA1 hash.
451 An abbreviated hash argument will be expanded to a full SHA1 hash
452 automatically, provided the abbreviation is unique.
453 .Pp
454 Show the status of each affected file, using the following status codes:
455 .Bl -column YXZ description
456 .It G Ta file was merged
457 .It C Ta file was merged and conflicts occurred during merge
458 .It ! Ta changes destined for a missing file were not merged
459 .It D Ta file was deleted
460 .It d Ta file's deletion was obstructed by local modifications
461 .It A Ta new file was added
462 .It ~ Ta changes destined for a non-regular file were not merged
463 .El
464 .Pp
465 The merged changes will appear as local changes in the work tree, which
466 may be viewed with
467 .Cm got diff ,
468 amended manually or with further
469 .Cm got cherrypick
470 comands,
471 committed with
472 .Cm got commit ,
473 or discarded again with
474 .Cm got revert .
475 .Pp
476 .Cm got cherrypick
477 will refuse to run if certain preconditions are not met.
478 If the work tree contains multiple base commits it must first be updated
479 to a single base commit with
480 .Cm got update .
481 If the work tree already contains files with merge conflicts, these
482 conflicts must be resolved first.
483 .It Cm ch
484 Short alias for
485 .Cm cherrypick .
486 .It Cm backout Ar commit
487 Reverse-merge changes from a single
488 .Ar commit
489 into the work tree.
490 The specified
491 .Ar commit
492 must be on the same branch as the work tree's base commit.
493 The expected argument is a reference or a commit ID SHA1 hash.
494 An abbreviated hash argument will be expanded to a full SHA1 hash
495 automatically, provided the abbreviation is unique.
496 .Pp
497 Show the status of each affected file, using the following status codes:
498 .Bl -column YXZ description
499 .It G Ta file was merged
500 .It C Ta file was merged and conflicts occurred during merge
501 .It ! Ta changes destined for a missing file were not merged
502 .It D Ta file was deleted
503 .It d Ta file's deletion was obstructed by local modifications
504 .It A Ta new file was added
505 .It ~ Ta changes destined for a non-regular file were not merged
506 .El
507 .Pp
508 The reverse-merged changes will appear as local changes in the work tree,
509 which may be viewed with
510 .Cm got diff ,
511 amended manually or with further
512 .Cm got cherrypick
513 comands,
514 committed with
515 .Cm got commit ,
516 or discarded again with
517 .Cm got revert .
518 .Pp
519 .Cm got backout
520 will refuse to run if certain preconditions are not met.
521 If the work tree contains multiple base commits it must first be updated
522 to a single base commit with
523 .Cm got update .
524 If the work tree already contains files with merge conflicts, these
525 conflicts must be resolved first.
526 .It Cm bo
527 Short alias for
528 .Cm backout .
529 .El
530 .Sh ENVIRONMENT
531 .Bl -tag -width GOT_AUTHOR
532 .It Ev GOT_AUTHOR
533 The author's name and email address for
534 .Cm got commit ,
535 for example:
536 .An Stefan Sperling Aq Mt stsp@openbsd.org
537 .It Ev VISUAL, Ev EDITOR
538 The editor spawned by
539 .Cm got commit .
540 .El
541 .Sh EXIT STATUS
542 .Ex -std got
543 .Sh EXAMPLES
544 .Pp
545 Clone an existing Git repository for use with
546 .Nm .
547 This step currently requires
548 .Xr git 1 :
549 .Pp
550 .Dl $ cd /var/git/
551 .Dl $ git clone --bare https://github.com/openbsd/src.git
552 .Pp
553 Check out a work tree from this Git repository to /usr/src:
554 .Pp
555 .Dl $ got checkout /var/git/src.git /usr/src
556 .Pp
557 View local changes in a work tree directory:
558 .Pp
559 .Dl $ got status
560 .Dl $ got diff | less
561 .Pp
562 In a work tree or a git repository directory, list all branch references:
563 .Pp
564 .Dl $ got branch -l
565 .Pp
566 In a work tree or a git repository directory, create a new branch called
567 .Dq unified-buffer-cache
568 which is forked off the
569 .Dq master
570 branch:
571 .Pp
572 .Dl $ got branch unified-buffer-cache master
573 .Pp
574 Switch an existing work tree to the branch
575 .Dq unified-buffer-cache .
576 Local changes in the work tree will be preserved and merged if necessary:
577 .Pp
578 .Dl $ got update -b unified-buffer-cache
579 .Pp
580 Create a new commit from local changes in a work tree directory.
581 This new commit will become the head commit of the work tree's current branch:
582 .Pp
583 .Dl $ got commit
584 .Pp
585 In a work tree or a git repository directory, view changes committed in
586 the 3 most recent commits to the work tree's branch, or the branch resolved
587 via the repository's HEAD reference, respectively:
588 .Pp
589 .Dl $ got log -p -l 3 -b
590 .Pp
591 Add new files and remove obsolete files in a work tree directory:
592 .Pp
593 .Dl $ got add sys/uvm/uvm_ubc.c
594 .Dl $ got rm sys/uvm/uvm_vnode.c
595 .Pp
596 Create a new commit from local changes in a work tree directory
597 with a pre-defined log message.
598 .Pp
599 .Dl $ got commit -m 'unify the buffer cache'
600 .Pp
601 Update any work tree checked out from the
602 .Dq unified-buffer-cache
603 branch to the latest commit on this branch:
604 .Pp
605 .Dl $ got update
606 .Pp
607 Fetch new upstream commits into the local repository's master branch.
608 This step currently requires
609 .Xr git 1 :
610 .Pp
611 .Dl $ cd /var/git/src.git
612 .Dl $ git fetch origin master:master
613 .Pp
614 Rebase the
615 .Dq unified-buffer-cache
616 branch on top of the new head commit of the
617 .Dq master
618 branch.
619 This step currently requires
620 .Xr git 1 :
621 .Pp
622 .Dl $ git clone /var/git/src.git ~/src-git-wt
623 .Dl $ cd ~/src-git-wt
624 .Dl $ git checkout unified-buffer-cache
625 .Dl $ git rebase master
626 .Dl $ git push -f
627 .Pp
628 Update the work tree to the newly rebased
629 .Dq unified-buffer-cache
630 branch:
631 .Pp
632 .Dl $ got update -b unified-buffer-cache
633 .Sh SEE ALSO
634 .Xr git-repository 5
635 .Xr got-worktree 5
636 .Sh AUTHORS
637 .An Stefan Sperling Aq Mt stsp@openbsd.org
638 .An Martin Pieuchot Aq Mt mpi@openbsd.org
639 .An joshua stein Aq Mt jcs@openbsd.org
640 .Sh CAVEATS
641 .Nm
642 is a work-in-progress and many commands remain to be implemented.
643 At present, the user has to fall back on
644 .Xr git 1
645 to perform many basic tasks.
646 .Pp
647 When working against a repository created with
648 .Dq git clone --bare ,
649 local commits to the
650 .Dq master
651 branch are discouraged, for now, if changes committed to the upstream
652 repository need to be tracked.
653 See the EXAMPLES section.