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