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 and exit immediately.
57 .It Fl V
58 Display program version and exit immediately.
59 .El
60 .Pp
61 The commands for
62 .Nm
63 are as follows:
64 .Bl -tag -width checkout
65 .It Cm init Ar repository-path
66 Create a new empty repository at the specified
67 .Ar repository-path .
68 .Pp
69 After
70 .Cm got init ,
71 the
72 .Cm got import
73 command must be used to populate the empty repository before
74 .Cm got checkout
75 can be used.
76 .Pp
77 .It Cm in
78 Short alias for
79 .Cm init .
80 .It Cm import [ Fl b Ar branch ] [ Fl m Ar message ] [ Fl r Ar repository-path ] [ Fl I Ar pattern ] directory
81 Create an initial commit in a repository from the file hierarchy
82 within the specified
83 .Ar directory .
84 The created commit will not have any parent commits, i.e. it will be a
85 root commit.
86 Also create a new reference which provides a branch name for the newly
87 created commit.
88 Show the path of each imported file to indicate progress.
89 .Pp
90 The
91 .Cm got import
92 command requires the
93 .Ev GOT_AUTHOR
94 environment variable to be set.
95 .Pp
96 The options for
97 .Cm got import
98 are as follows:
99 .Bl -tag -width Ds
100 .It Fl b Ar branch
101 Create the specified
102 .Ar branch
103 instead of creating the default branch
104 .Dq master .
105 Use of this option is required if the
106 .Dq master
107 branch already exists.
108 .It Fl m Ar message
109 Use the specified log message when creating the new commit.
110 Without the
111 .Fl m
112 option,
113 .Cm got import
114 opens a temporary file in an editor where a log message can be written.
115 .It Fl r Ar repository-path
116 Use the repository at the specified path.
117 If not specified, assume the repository is located at or above the current
118 working directory.
119 .It Fl I Ar pattern
120 Ignore files or directories with a name which matches the specified
121 .Ar pattern .
122 This option may be specified multiple times to build a list of ignore patterns.
123 The
124 .Ar pattern
125 follows the globbing rules documented in
126 .Xr glob 7 .
127 .El
128 .It Cm im
129 Short alias for
130 .Cm import .
131 .It Cm checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
132 Copy files from a repository into a new work tree.
133 If the
134 .Ar work tree path
135 is not specified, either use the last component of
136 .Ar repository path ,
137 or if a
138 .Ar path prefix
139 was specified use the last component of
140 .Ar path prefix .
141 .Pp
142 The options for
143 .Cm got checkout
144 are as follows:
145 .Bl -tag -width Ds
146 .It Fl b Ar branch
147 Check out files from a commit on the specified
148 .Ar branch .
149 If this option is not specified, a branch resolved via the repository's HEAD
150 reference will be used.
151 .It Fl c Ar commit
152 Check out files from the specified
153 .Ar commit
154 on the selected branch.
155 The expected argument is a commit ID SHA1 hash or an existing reference
156 which will be resolved to a commit ID.
157 An abbreviated hash argument will be expanded to a full SHA1 hash
158 automatically, provided the abbreviation is unique.
159 If this option is not specified, the most recent commit on the selected
160 branch will be used.
161 .It Fl p Ar path-prefix
162 Restrict the work tree to a subset of the repository's tree hierarchy.
163 Only files beneath the specified
164 .Ar path-prefix
165 will be checked out.
166 .El
167 .It Cm co
168 Short alias for
169 .Cm checkout .
170 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ... ]
171 Update an existing work tree to a different commit.
172 Show the status of each affected file, using the following status codes:
173 .Bl -column YXZ description
174 .It U Ta file was updated and contained no local changes
175 .It G Ta file was updated and local changes were merged cleanly
176 .It C Ta file was updated and conflicts occurred during merge
177 .It D Ta file was deleted
178 .It A Ta new file was added
179 .It ~ Ta versioned file is obstructed by a non-regular file
180 .It ! Ta a missing versioned file was restored
181 .El
182 .Pp
183 If no
184 .Ar path
185 is specified, update the entire work tree.
186 Otherwise, restrict the update operation to files at or within the
187 specified paths.
188 Each path is required to exist in the update operation's target commit.
189 Files in the work tree outside specified paths will remain unchanged and
190 will retain their previously recorded base commit.
191 Some
192 .Nm
193 commands may refuse to run while the work tree contains files from
194 multiple base commits.
195 The base commit of such a work tree can be made consistent by running
196 .Cm got update
197 across the entire work tree.
198 Specifying a
199 .Ar path
200 is incompatible with the
201 .Fl b
202 option.
203 .Pp
204 .Cm got update
205 cannot update paths with staged changes.
206 If changes have been staged with
207 .Cm got stage ,
208 these changes must first be comitted with
209 .Cm got commit
210 or unstaged with
211 .Cm got unstage .
212 .Pp
213 The options for
214 .Cm got update
215 are as follows:
216 .Bl -tag -width Ds
217 .It Fl b Ar branch
218 Switch the work tree's branch reference to the specified
219 .Ar branch
220 before updating the work tree.
221 This option requires that all paths in the work tree are updated.
222 .It Fl c Ar commit
223 Update the work tree to the specified
224 .Ar commit .
225 The expected argument is a commit ID SHA1 hash or an existing reference
226 which will be resolved to a commit ID.
227 An abbreviated hash argument will be expanded to a full SHA1 hash
228 automatically, provided the abbreviation is unique.
229 If this option is not specified, the most recent commit on the work tree's
230 branch will be used.
231 .El
232 .It Cm up
233 Short alias for
234 .Cm update .
235 .It Cm status [ Ar path ... ]
236 Show the current modification status of files in a work tree,
237 using the following status codes:
238 .Bl -column YXZ description
239 .It M Ta modified file
240 .It A Ta file scheduled for addition in next commit
241 .It D Ta file scheduled for deletion in next commit
242 .It C Ta modified or added file which contains merge conflicts
243 .It ! Ta versioned file was expected on disk but is missing
244 .It ~ Ta versioned file is obstructed by a non-regular file
245 .It ? Ta unversioned item not tracked by
246 .Nm
247 .El
248 .Pp
249 If no
250 .Ar path
251 is specified, show modifications in the entire work tree.
252 Otherwise, show modifications at or within the specified paths.
253 .Pp
254 If changes have been staged with
255 .Cm got stage ,
256 staged changes are shown in the second output column, using the following
257 status codes:
258 .Bl -column YXZ description
259 .It M Ta file modification is staged
260 .It A Ta file addition is staged
261 .It D Ta file deletion is staged
262 .El
263 .Pp
264 If a path has staged changes, modification status of files shown
265 in the first output column is relative to the staged changes:
266 .Bl -column YXZ description
267 .It MM Ta modified file was modified again after being staged
268 .It MA Ta added file was modified after being staged
269 .El
270 .It Cm st
271 Short alias for
272 .Cm status .
273 .It Cm log [ Fl c Ar commit ] [ Fl C Ar number ] [ Fl f ] [ Fl l Ar N ] [ Fl p ] [ Fl r Ar repository-path ] [ path ]
274 Display history of a repository.
275 If a
276 .Ar path
277 is specified, show only commits which modified this path.
278 .Pp
279 The options for
280 .Cm got log
281 are as follows:
282 .Bl -tag -width Ds
283 .It Fl c Ar commit
284 Start traversing history at the specified
285 .Ar commit .
286 The expected argument is a commit ID SHA1 hash or an existing reference
287 which will be resolved to a commit ID.
288 An abbreviated hash argument will be expanded to a full SHA1 hash
289 automatically, provided the abbreviation is unique.
290 If this option is not specified, default to the work tree's current branch
291 if invoked in a work tree, or to the repository's HEAD reference.
292 .It Fl C Ar number
293 Set the number of context lines shown in diffs with
294 .Fl p .
295 By default, 3 lines of context are shown.
296 .It Fl f
297 Restrict history traversal to the first parent of each commit.
298 This shows the linear history of the current branch only.
299 Merge commits which affected the current branch will be shown but
300 individual commits which originated on other branches will be omitted.
301 .It Fl l Ar N
302 Limit history traversal to a given number of commits.
303 .It Fl p
304 Display the patch of modifications made in each commit.
305 .It Fl r Ar repository-path
306 Use the repository at the specified path.
307 If not specified, assume the repository is located at or above the current
308 working directory.
309 If this directory is a
310 .Nm
311 work tree, use the repository path associated with this work tree.
312 .El
313 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Fl s ] [ Ar object1 Ar object2 | Ar path ]
314 When invoked within a work tree with less than two arguments, display
315 uncommitted changes in the work tree.
316 If a
317 .Ar path
318 is specified, only show changes within this path.
319 .Pp
320 If two arguments are provided, treat each argument as a reference,
321 or an object ID SHA1 hash, and display differences between these objects.
322 Both objects must be of the same type (blobs, trees, or commits).
323 An abbreviated hash argument will be expanded to a full SHA1 hash
324 automatically, provided the abbreviation is unique.
325 .Pp
326 The options for
327 .Cm got diff
328 are as follows:
329 .Bl -tag -width Ds
330 .It Fl C Ar number
331 Set the number of context lines shown in the diff.
332 By default, 3 lines of context are shown.
333 .It Fl r Ar repository-path
334 Use the repository at the specified path.
335 If not specified, assume the repository is located at or above the current
336 working directory.
337 If this directory is a
338 .Nm
339 work tree, use the repository path associated with this work tree.
340 .It Fl s
341 Show changes staged with
342 .Cm got stage
343 instead of showing local changes.
344 This option is only valid when
345 .Cm got diff
346 is invoked in a work tree.
347 .El
348 .It Cm di
349 Short alias for
350 .Cm diff .
351 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
352 Display line-by-line history of a file at the specified path.
353 .Pp
354 The options for
355 .Cm got blame
356 are as follows:
357 .Bl -tag -width Ds
358 .It Fl c Ar commit
359 Start traversing history at the specified
360 .Ar commit .
361 The expected argument is a commit ID SHA1 hash or an existing reference
362 which will be resolved to a commit ID.
363 An abbreviated hash argument will be expanded to a full SHA1 hash
364 automatically, provided the abbreviation is unique.
365 .It Fl r Ar repository-path
366 Use the repository at the specified path.
367 If not specified, assume the repository is located at or above the current
368 working directory.
369 If this directory is a
370 .Nm
371 work tree, use the repository path associated with this work tree.
372 .El
373 .It Cm bl
374 Short alias for
375 .Cm blame .
376 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
377 Display a listing of files and directories at the specified
378 directory path in the repository.
379 Entries shown in this listing may carry one of the following trailing
380 annotations:
381 .Bl -column YXZ description
382 .It / Ta entry is a directory
383 .It * Ta entry is an executable file
384 .El
385 .Pp
386 If no
387 .Ar path
388 is specified, list the repository path corresponding to the current
389 directory of the work tree, or the root directory of the repository
390 if there is no work tree.
391 .Pp
392 The options for
393 .Cm got tree
394 are as follows:
395 .Bl -tag -width Ds
396 .It Fl c Ar commit
397 List files and directories as they appear in the specified
398 .Ar commit .
399 The expected argument is a commit ID SHA1 hash or an existing reference
400 which will be resolved to a commit ID.
401 An abbreviated hash argument will be expanded to a full SHA1 hash
402 automatically, provided the abbreviation is unique.
403 .It Fl r Ar repository-path
404 Use the repository at the specified path.
405 If not specified, assume the repository is located at or above the current
406 working directory.
407 If this directory is a
408 .Nm
409 work tree, use the repository path associated with this work tree.
410 .It Fl i
411 Show object IDs of files (blob objects) and directories (tree objects).
412 .It Fl R
413 Recurse into sub-directories in the repository.
414 .El
415 .It Cm tr
416 Short alias for
417 .Cm tree .
418 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
419 Manage references in a repository.
420 .Pp
421 If no options are passed, expect two arguments and attempt to create,
422 or update, the reference with the given
423 .Ar name ,
424 and make it point at the given
425 .Ar target .
426 The target may be an object ID SHA1 hash or an existing reference which
427 will be resolved to an object ID.
428 An abbreviated hash argument will be expanded to a full SHA1 hash
429 automatically, provided the abbreviation is unique.
430 .Pp
431 The options for
432 .Cm got ref
433 are as follows:
434 .Bl -tag -width Ds
435 .It Fl r Ar repository-path
436 Use the repository at the specified path.
437 If not specified, assume the repository is located at or above the current
438 working directory.
439 If this directory is a
440 .Nm
441 work tree, use the repository path associated with this work tree.
442 .It Fl l
443 List all existing references in the repository.
444 .It Fl d Ar name
445 Delete the reference with the specified name from the repository.
446 .El
447 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
448 Manage branches in a repository.
449 .Pp
450 Branches are managed via references which live in the
451 .Dq refs/heads/
452 reference namespace.
453 The
454 .Cm got branch
455 command operates on references in this namespace only.
456 .Pp
457 If no options are passed, expect one or two arguments and attempt to create
458 a branch with the given
459 .Ar name ,
460 and make it point at the given
461 .Ar base-branch .
462 If no
463 .Ar base-branch
464 is specified, default to the work tree's current branch if invoked in a
465 work tree, or to the repository's HEAD reference.
466 .Pp
467 The options for
468 .Cm got branch
469 are as follows:
470 .Bl -tag -width Ds
471 .It Fl r Ar repository-path
472 Use the repository at the specified path.
473 If not specified, assume the repository is located at or above the current
474 working directory.
475 If this directory is a
476 .Nm
477 work tree, use the repository path associated with this work tree.
478 .It Fl l
479 List all existing branches in the repository.
480 If invoked in a work tree, the work tree's current branch is shown
481 with one the following annotations:
482 .Bl -column YXZ description
483 .It * Ta work tree's base commit matches the branch tip
484 .It ~ Ta work tree's base commit is out-of-date
485 .El
486 .It Fl d Ar name
487 Delete the branch with the specified name from the repository.
488 Only the branch reference is deleted.
489 Any commit, tree, and blob objects belonging to the branch
490 remain in the repository and may be removed separately with
491 Git's garbage collector.
492 .El
493 .It Cm br
494 Short alias for
495 .Cm branch .
496 .It Cm add Ar file-path ...
497 Schedule unversioned files in a work tree for addition to the
498 repository in the next commit.
499 .It Cm remove Ar file-path ...
500 Remove versioned files from a work tree and schedule them for deletion
501 from the repository in the next commit.
502 .Pp
503 The options for
504 .Cm got remove
505 are as follows:
506 .Bl -tag -width Ds
507 .It Fl f
508 Perform the operation even if a file contains uncommitted modifications.
509 .El
510 .It Cm rm
511 Short alias for
512 .Cm remove .
513 .It Cm revert Ar file-path ...
514 Revert any uncommited changes in files at the specified paths.
515 File contents will be overwritten with those contained in the
516 work tree's base commit. There is no way to bring discarded
517 changes back after
518 .Cm got revert !
519 .Pp
520 If a file was added with
521 .Cm got add
522 it will become an unversioned file again.
523 If a file was deleted with
524 .Cm got remove
525 it will be restored.
526 .It Cm rv
527 Short alias for
528 .Cm revert .
529 .It Cm commit [ Fl m Ar message ] [ path ... ]
530 Create a new commit in the repository from changes in a work tree
531 and use this commit as the new base commit for the work tree.
532 If no
533 .Ar path
534 is specified, commit all changes in the work tree.
535 Otherwise, commit changes at or within the specified paths.
536 .Pp
537 If changes have been explicitly staged for commit with
538 .Cm got stage,
539 only commit staged changes and reject any specified paths which
540 have not been staged.
541 .Pp
542 Show the status of each affected file, using the following status codes:
543 .Bl -column YXZ description
544 .It M Ta modified file
545 .It D Ta file was deleted
546 .It A Ta new file was added
547 .El
548 .Pp
549 Files which are not part of the new commit will retain their previously
550 recorded base commit.
551 Some
552 .Nm
553 commands may refuse to run while the work tree contains files from
554 multiple base commits.
555 The base commit of such a work tree can be made consistent by running
556 .Cm got update
557 across the entire work tree.
558 .Pp
559 The
560 .Cm got commit
561 command requires the
562 .Ev GOT_AUTHOR
563 environment variable to be set.
564 .Pp
565 The options for
566 .Cm got commit
567 are as follows:
568 .Bl -tag -width Ds
569 .It Fl m Ar message
570 Use the specified log message when creating the new commit.
571 Without the
572 .Fl m
573 option,
574 .Cm got commit
575 opens a temporary file in an editor where a log message can be written.
576 .El
577 .Pp
578 .Cm got commit
579 will refuse to run if certain preconditions are not met.
580 If the work tree's current branch is not in the
581 .Dq refs/heads/
582 reference namespace, new commits may not be created on this branch.
583 Local changes may only be committed if they are based on file content
584 found in the most recent commit on the work tree's branch.
585 If a path is found to be out of date,
586 .Cm got update
587 must be used first in order to merge local changes with changes made
588 in the repository.
589 .It Cm ci
590 Short alias for
591 .Cm commit .
592 .It Cm cherrypick Ar commit
593 Merge changes from a single
594 .Ar commit
595 into the work tree.
596 The specified
597 .Ar commit
598 must be on a different branch than the work tree's base commit.
599 The expected argument is a reference or a commit ID SHA1 hash.
600 An abbreviated hash argument will be expanded to a full SHA1 hash
601 automatically, provided the abbreviation is unique.
602 .Pp
603 Show the status of each affected file, using the following status codes:
604 .Bl -column YXZ description
605 .It G Ta file was merged
606 .It C Ta file was merged and conflicts occurred during merge
607 .It ! Ta changes destined for a missing file were not merged
608 .It D Ta file was deleted
609 .It d Ta file's deletion was obstructed by local modifications
610 .It A Ta new file was added
611 .It ~ Ta changes destined for a non-regular file were not merged
612 .El
613 .Pp
614 The merged changes will appear as local changes in the work tree, which
615 may be viewed with
616 .Cm got diff ,
617 amended manually or with further
618 .Cm got cherrypick
619 comands,
620 committed with
621 .Cm got commit ,
622 or discarded again with
623 .Cm got revert .
624 .Pp
625 .Cm got cherrypick
626 will refuse to run if certain preconditions are not met.
627 If the work tree contains multiple base commits it must first be updated
628 to a single base commit with
629 .Cm got update .
630 If the work tree already contains files with merge conflicts, these
631 conflicts must be resolved first.
632 .It Cm cy
633 Short alias for
634 .Cm cherrypick .
635 .It Cm backout Ar commit
636 Reverse-merge changes from a single
637 .Ar commit
638 into the work tree.
639 The specified
640 .Ar commit
641 must be on the same branch as the work tree's base commit.
642 The expected argument is a reference or a commit ID SHA1 hash.
643 An abbreviated hash argument will be expanded to a full SHA1 hash
644 automatically, provided the abbreviation is unique.
645 .Pp
646 Show the status of each affected file, using the following status codes:
647 .Bl -column YXZ description
648 .It G Ta file was merged
649 .It C Ta file was merged and conflicts occurred during merge
650 .It ! Ta changes destined for a missing file were not merged
651 .It D Ta file was deleted
652 .It d Ta file's deletion was obstructed by local modifications
653 .It A Ta new file was added
654 .It ~ Ta changes destined for a non-regular file were not merged
655 .El
656 .Pp
657 The reverse-merged changes will appear as local changes in the work tree,
658 which may be viewed with
659 .Cm got diff ,
660 amended manually or with further
661 .Cm got backout
662 comands,
663 committed with
664 .Cm got commit ,
665 or discarded again with
666 .Cm got revert .
667 .Pp
668 .Cm got backout
669 will refuse to run if certain preconditions are not met.
670 If the work tree contains multiple base commits it must first be updated
671 to a single base commit with
672 .Cm got update .
673 If the work tree already contains files with merge conflicts, these
674 conflicts must be resolved first.
675 .It Cm bo
676 Short alias for
677 .Cm backout .
678 .It Cm rebase [ Fl a ] [ Fl c] [ Ar branch ]
679 Rebase commits on the specified
680 .Ar branch
681 onto the tip of the current branch of the work tree.
682 The
683 .Ar branch
684 must share common ancestry with the work tree's current branch.
685 Rebasing begins with the first descendent commit of the youngest
686 common ancestor commit shared by the specified
687 .Ar branch
688 and the work tree's current branch, and stops once the tip commit
689 of the specified
690 .Ar branch
691 has been rebased.
692 .Pp
693 Rebased commits are accumulated on a temporary branch which the work tree
694 will remain switched to throughout the entire rebase operation.
695 Commits on this branch represent the same changes with the same log
696 messages as their counterparts on the original
697 .Ar branch ,
698 but with different commit IDs.
699 Once rebasing has completed successfully, the temporary branch becomes
700 the new version of the specified
701 .Ar branch
702 and the work tree is automatically switched to it.
703 .Pp
704 While rebasing commits, show the status of each affected file,
705 using the following status codes:
706 .Bl -column YXZ description
707 .It G Ta file was merged
708 .It C Ta file was merged and conflicts occurred during merge
709 .It ! Ta changes destined for a missing file were not merged
710 .It D Ta file was deleted
711 .It d Ta file's deletion was obstructed by local modifications
712 .It A Ta new file was added
713 .It ~ Ta changes destined for a non-regular file were not merged
714 .El
715 .Pp
716 If merge conflicts occur the rebase operation is interrupted and may
717 be continued once conflicts have been resolved.
718 Alternatively, the rebase operation may be aborted which will leave
719 .Ar branch
720 unmodified and the work tree switched back to its original branch.
721 .Pp
722 If a merge conflict is resolved in a way which renders the merged
723 change into a no-op change, the corresponding commit will be elided
724 when the rebase operation continues.
725 .Pp
726 .Cm got rebase
727 will refuse to run if certain preconditions are not met.
728 If the work tree contains multiple base commits it must first be updated
729 to a single base commit with
730 .Cm got update .
731 If changes have been staged with
732 .Cm got stage ,
733 these changes must first be comitted with
734 .Cm got commit
735 or unstaged with
736 .Cm got unstage .
737 If the work tree contains local changes, these changes must first be
738 committed with
739 .Cm got commit
740 or reverted with
741 .Cm got revert .
742 If the
743 .Ar branch
744 contains changes to files outside of the work tree's path prefix,
745 the work tree cannot be used to rebase this branch.
746 .Pp
747 The
748 .Cm got update
749 and
750 .Cm got commit
751 commands will refuse to run while a rebase operation is in progress.
752 Other commands which manipulate the work tree may be used for
753 conflict resolution purposes.
754 .Pp
755 The options for
756 .Cm got rebase
757 are as follows:
758 .Bl -tag -width Ds
759 .It Fl a
760 Abort an interrupted rebase operation.
761 If this option is used, no further command-line arguments are allowed.
762 .It Fl c
763 Continue an interrupted rebase operation.
764 If this option is used, no further command-line arguments are allowed.
765 .El
766 .It Cm rb
767 Short alias for
768 .Cm rebase .
769 .It Cm histedit [ Fl a ] [ Fl c] [ Fl F Ar histedit-script ]
770 Edit commit history between the work tree's current base commit and
771 the tip commit of the work tree's current branch.
772 .Pp
773 Editing of commit history is controlled via a
774 .Ar histedit script
775 which can be edited interactively or passed on the command line.
776 The format of the histedit script is line-based.
777 Each line in the script begins with a command name, followed by
778 whitespace and an argument.
779 For most commands, the expected argument is a commit ID SHA1 hash.
780 Any remaining text on the line is ignored.
781 Lines which begin with the
782 .Sq #
783 character are ignored entirely.
784 .Pp
785 The available commands are as follows:
786 .Bl -column YXZ pick-commit
787 .It pick Ar commit Ta Use the specified commit as it is.
788 .It edit Ar commit Ta Use the specified commit but once changes have been
789 merged into the work tree interrupt the histedit operation for amending.
790 .It fold Ar commit Ta Combine the specified commit with the next commit
791 listed further below that will be used.
792 .It drop Ar commit Ta Remove this commit from the edited history.
793 .It mesg Ar log-message Ta Use the specified single-line log message for
794 the commit on the previous line.
795 If the log message argument is left empty, open an editor where a new
796 log message can be written.
797 .El
798 .Pp
799 Every commit in the history being edited must be mentioned in the script.
800 Lines may be re-ordered to change the order of commits in the edited history.
801 .Pp
802 Edited commits are accumulated on a temporary branch which the work tree
803 will remain switched to throughout the entire histedit operation.
804 Once history editing has completed successfully, the temporary branch becomes
805 the new version of the work tree's branch and the work tree is automatically
806 switched to it.
807 .Pp
808 While merging commits, show the status of each affected file,
809 using the following status codes:
810 .Bl -column YXZ description
811 .It G Ta file was merged
812 .It C Ta file was merged and conflicts occurred during merge
813 .It ! Ta changes destined for a missing file were not merged
814 .It D Ta file was deleted
815 .It d Ta file's deletion was obstructed by local modifications
816 .It A Ta new file was added
817 .It ~ Ta changes destined for a non-regular file were not merged
818 .El
819 .Pp
820 If merge conflicts occur the histedit operation is interrupted and may
821 be continued once conflicts have been resolved.
822 Alternatively, the histedit operation may be aborted which will leave
823 the work tree switched back to its original branch.
824 .Pp
825 If a merge conflict is resolved in a way which renders the merged
826 change into a no-op change, the corresponding commit will be elided
827 when the histedit operation continues.
828 .Pp
829 .Cm got histedit
830 will refuse to run if certain preconditions are not met.
831 If the work tree's current branch is not in the
832 .Dq refs/heads/
833 reference namespace, the history of the branch may not be edited.
834 If the work tree contains multiple base commits it must first be updated
835 to a single base commit with
836 .Cm got update .
837 If changes have been staged with
838 .Cm got stage ,
839 these changes must first be comitted with
840 .Cm got commit
841 or unstaged with
842 .Cm got unstage .
843 If the work tree contains local changes, these changes must first be
844 committed with
845 .Cm got commit
846 or reverted with
847 .Cm got revert .
848 If the edited history contains changes to files outside of the work tree's
849 path prefix, the work tree cannot be used to edit the history of this branch.
850 .Pp
851 The
852 .Cm got update
853 command will refuse to run while a histedit operation is in progress.
854 Other commands which manipulate the work tree may be used, and the
855 .Cm got commit
856 command may be used to commit arbitrary changes to the temporary branch
857 while the histedit operation is interrupted.
858 .Pp
859 The options for
860 .Cm got histedit
861 are as follows:
862 .Bl -tag -width Ds
863 .It Fl a
864 Abort an interrupted histedit operation.
865 If this option is used, no further command-line arguments are allowed.
866 .It Fl c
867 Continue an interrupted histedit operation.
868 If this option is used, no further command-line arguments are allowed.
869 .El
870 .It Cm he
871 Short alias for
872 .Cm histedit .
873 .It Cm stage [ Fl l ] Ar file-path ...
874 Stage local changes at the specified paths for inclusion in the next commit.
875 Paths may be staged if they are added, modified, or deleted according to
876 .Cm got status .
877 .Pp
878 Show the status of each affected file, using the following status codes:
879 .Bl -column YXZ description
880 .It A Ta file addition has been staged
881 .It M Ta file modification has been staged
882 .It D Ta file deletion has been staged
883 .El
884 .Pp
885 Staged file contents are saved in newly created blob objects in the repository.
886 These blobs will be referred to by tree objects once staged changes have been
887 committed.
888 .Pp
889 Staged changes affect the behaviour of
890 .Cm got commit ,
891 .Cm got status ,
892 and
893 .Cm got diff .
894 While paths with staged changes exist, the
895 .Cm got commit
896 command will refuse to commit any paths which do not have staged changes.
897 Local changes created on top of staged changes can only be committed if
898 the path is staged again, or if the staged changes are committed first.
899 The
900 .Cm got status
901 command will show both local changes and staged changes.
902 The
903 .Cm got diff
904 command is able to display local changes relative to staged changes,
905 and to display staged changes relative to the repository.
906 The
907 .Cm got revert
908 command cannot revert staged changes but may be used to revert
909 local changes relative to staged changes.
910 .Pp
911 The options for
912 .Cm got stage
913 are as follows:
914 .Bl -tag -width Ds
915 .It Fl l
916 Instead of staging new changes, list paths which are already staged,
917 along with the IDs of staged blob objects and stage status codes.
918 If paths were provided in the command line show the staged paths
919 among the specified paths. Otherwise, show all staged paths.
920 .El
921 .Pp
922 .Cm got stage
923 will refuse to run if certain preconditions are not met.
924 If a file contains merge conflicts, these conflicts must be resolved first.
925 If a file is found to be out of date relative to the head commit on the
926 work tree's current branch, the file must be updated with
927 .Cm got update
928 before it can be staged (however, this does not prevent the file from
929 becoming out-of-date at some point after having been staged).
930 .Pp
931 The
932 .Cm got update ,
933 .Cm got rebase ,
934 and
935 .Cm got histedit
936 commands will refuse to run while staged changes exist.
937 If staged changes cannot be committed because a staged path
938 is out of date, the path must be unstaged with
939 .Cm got unstage
940 before it can be updated with
941 .Cm got update ,
942 and may then be staged again if necessary.
943 .It Cm sg
944 Short alias for
945 .Cm stage .
946 .It Cm unstage [ Ar path ... ]
947 Merge staged changes back into the work tree and put affected paths
948 back into non-staged status.
949 If no
950 .Ar path
951 is specified, unstage all staged changes across the entire work tree.
952 .Pp
953 Show the status of each affected file, using the following status codes:
954 .Bl -column YXZ description
955 .It G Ta file was unstaged
956 .It C Ta file was unstaged and conflicts occurred during merge
957 .It ! Ta changes destined for a missing file were not merged
958 .It D Ta file was staged as deleted and still is deleted
959 .It d Ta file's deletion was obstructed by local modifications
960 .It ~ Ta changes destined for a non-regular file were not merged
961 .El
962 .It Cm ug
963 Short alias for
964 .Cm unstage .
965 .El
966 .Sh ENVIRONMENT
967 .Bl -tag -width GOT_AUTHOR
968 .It Ev GOT_AUTHOR
969 The author's name and email address for
970 .Cm got commit
971 and
972 .Cm got import ,
973 for example:
974 .An Stefan Sperling Aq Mt stsp@openbsd.org
975 .It Ev VISUAL, Ev EDITOR
976 The editor spawned by
977 .Cm got commit .
978 .El
979 .Sh EXIT STATUS
980 .Ex -std got
981 .Sh EXAMPLES
982 Clone an existing Git repository for use with
983 .Nm .
984 This step currently requires
985 .Xr git 1 :
986 .Pp
987 .Dl $ cd /var/git/
988 .Dl $ git clone --bare https://github.com/openbsd/src.git
989 .Pp
990 Alternatively, for quick and dirty local testing of
991 .Nm
992 a new Git repository could be created and populated with files,
993 e.g. from a temporary CVS checkout located at
994 .Pa /tmp/src :
995 .Pp
996 .Dl $ got init /var/git/src.git
997 .Dl $ got import -r /var/git/src.git -I CVS -I obj /tmp/src
998 .Pp
999 Check out a work tree from the Git repository to /usr/src:
1000 .Pp
1001 .Dl $ got checkout /var/git/src.git /usr/src
1002 .Pp
1003 View local changes in a work tree directory:
1004 .Pp
1005 .Dl $ got status
1006 .Dl $ got diff | less
1007 .Pp
1008 In a work tree or a git repository directory, list all branch references:
1009 .Pp
1010 .Dl $ got branch -l
1011 .Pp
1012 In a work tree or a git repository directory, create a new branch called
1013 .Dq unified-buffer-cache
1014 which is forked off the
1015 .Dq master
1016 branch:
1017 .Pp
1018 .Dl $ got branch unified-buffer-cache master
1019 .Pp
1020 Switch an existing work tree to the branch
1021 .Dq unified-buffer-cache .
1022 Local changes in the work tree will be preserved and merged if necessary:
1023 .Pp
1024 .Dl $ got update -b unified-buffer-cache
1025 .Pp
1026 Create a new commit from local changes in a work tree directory.
1027 This new commit will become the head commit of the work tree's current branch:
1028 .Pp
1029 .Dl $ got commit
1030 .Pp
1031 In a work tree or a git repository directory, view changes committed in
1032 the 3 most recent commits to the work tree's branch, or the branch resolved
1033 via the repository's HEAD reference, respectively:
1034 .Pp
1035 .Dl $ got log -p -l 3 -f
1036 .Pp
1037 Add new files and remove obsolete files in a work tree directory:
1038 .Pp
1039 .Dl $ got add sys/uvm/uvm_ubc.c
1040 .Dl $ got remove sys/uvm/uvm_vnode.c
1041 .Pp
1042 Create a new commit from local changes in a work tree directory
1043 with a pre-defined log message.
1044 .Pp
1045 .Dl $ got commit -m 'unify the buffer cache'
1046 .Pp
1047 Update any work tree checked out from the
1048 .Dq unified-buffer-cache
1049 branch to the latest commit on this branch:
1050 .Pp
1051 .Dl $ got update
1052 .Pp
1053 Roll file content on the unified-buffer-cache branch back by one commit,
1054 and then fetch the rolled-back change into the work tree as a local change
1055 to be amended and perhaps committed again:
1056 .Pp
1057 .Dl $ got backout unified-buffer-cache
1058 .Dl $ got commit -m 'roll back previous'
1059 .Dl $ # now back out the previous backout :-)
1060 .Dl $ got backout unified-buffer-cache
1061 .Pp
1062 Fetch new upstream commits into the local repository's master branch.
1063 This step currently requires
1064 .Xr git 1 :
1065 .Pp
1066 .Dl $ cd /var/git/src.git
1067 .Dl $ git fetch origin master:master
1068 .Pp
1069 Rebase the
1070 .Dq unified-buffer-cache
1071 branch on top of the new head commit of the
1072 .Dq master
1073 branch.
1074 .Pp
1075 .Dl $ got update -b master
1076 .Dl $ got rebase unified-buffer-cache
1077 .Pp
1078 Create a patch from all changes on the unified-buffer-cache branch.
1079 The patch can be mailed out for review and applied to OpenBSD's CVS tree:
1080 .Pp
1081 .Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff
1082 .Pp
1083 Edit the entire commit history of the
1084 .Dq unified-buffer-cache
1085 branch:
1086 .Pp
1087 .Dl $ got update -b unified-buffer-cache
1088 .Dl $ got update -c master
1089 .Dl $ got histedit
1090 .Pp
1091 Additional steps are necessary if local changes need to be pushed back
1092 to the remote repository, which currently requires
1093 .Cm git fetch
1094 and
1095 .Cm git push .
1096 Before working against existing branches in a repository cloned with
1097 .Dq git clone --bare ,
1098 a Git
1099 .Dq refspec
1100 must be configured to map all references in the remote repository
1101 into the
1102 .Dq refs/remotes
1103 namespace of the local repository.
1104 This can achieved by setting Git's
1105 .Pa remote.origin.fetch
1106 configuration variable to the value
1107 .Dq +refs/heads/*:refs/remotes/origin/*
1108 with the
1109 .Cm git config
1110 command:
1111 .Pp
1112 .Dl $ cd /var/git/repo
1113 .Dl $ git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
1114 .Pp
1115 Alternatively, the following
1116 .Pa fetch
1117 configuration item can be added manually to the Git repository's
1118 .Pa config
1119 file:
1120 .Pp
1121 .Dl [remote "origin"]
1122 .Dl url = ...
1123 .Dl fetch = +refs/heads/*:refs/remotes/origin/*
1124 .Pp
1125 This configuration leaves the local repository's
1126 .Dq refs/heads
1127 namespace free for use by local branches checked out with
1128 .Cm got checkout
1129 and, if needed, created with
1130 .Cm got branch .
1131 .Pp
1132 Branches in the
1133 .Dq remotes/origin
1134 namespace can be updated with incoming changes from the remote
1135 repository with
1136 .Cm git fetch :
1137 .Pp
1138 .Dl $ cd /var/git/repo
1139 .Dl $ git fetch
1140 .Pp
1141 Before outgoing changes on the local
1142 .Dq master
1143 branch can be pushed to the remote repository, the local
1144 .Dq master
1145 branch must be rebased onto the
1146 .Dq origin/master
1147 branch:
1148 .Pp
1149 .Dl $ got update -b origin/master
1150 .Dl $ got rebase master
1151 .Pp
1152 Changes on the local
1153 .Dq master
1154 branch can then be pushed to the remote
1155 repository with
1156 .Cm git push :
1157 .Pp
1158 .Dl $ cd /var/git/repo
1159 .Dl $ git push origin master
1160 .Pp
1161 .Sh SEE ALSO
1162 .Xr tog 1 ,
1163 .Xr git-repository 5 ,
1164 .Xr got-worktree 5
1165 .Sh AUTHORS
1166 .An Stefan Sperling Aq Mt stsp@openbsd.org
1167 .An Martin Pieuchot Aq Mt mpi@openbsd.org
1168 .An joshua stein Aq Mt jcs@openbsd.org
1169 .Sh CAVEATS
1170 .Nm
1171 is a work-in-progress and many commands remain to be implemented.
1172 At present, the user has to fall back on
1173 .Xr git 1
1174 to perform many tasks, in particular tasks related to repository
1175 administration and tasks which require a network connection.