Blob


1 .\"
2 .\" Copyright (c) 2017 Martin Pieuchot
3 .\" Copyright (c) 2018, 2019, 2020 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 precede 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, -version
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 .It Cm in
77 Short alias for
78 .Cm init .
79 .It Cm import Oo Fl b Ar branch Oc Oo Fl m Ar message Oc Oo Fl r Ar repository-path Oc Oo Fl I Ar pattern Oc Ar directory
80 Create an initial commit in a repository from the file hierarchy
81 within the specified
82 .Ar directory .
83 The created commit will not have any parent commits, i.e. it will be a
84 root commit.
85 Also create a new reference which provides a branch name for the newly
86 created commit.
87 Show the path of each imported file to indicate progress.
88 .Pp
89 The
90 .Cm got import
91 command requires the
92 .Ev GOT_AUTHOR
93 environment variable to be set,
94 unless Git's
95 .Dv user.name
96 and
97 .Dv user.email
98 configuration settings can be obtained from the repository's
99 .Pa .git/config
100 file or from Git's global
101 .Pa ~/.gitconfig
102 configuration file.
103 .Pp
104 The options for
105 .Cm got import
106 are as follows:
107 .Bl -tag -width Ds
108 .It Fl b Ar branch
109 Create the specified
110 .Ar branch
111 instead of creating the default branch
112 .Dq main .
113 Use of this option is required if the
114 .Dq main
115 branch already exists.
116 .It Fl m Ar message
117 Use the specified log message when creating the new commit.
118 Without the
119 .Fl m
120 option,
121 .Cm got import
122 opens a temporary file in an editor where a log message can be written.
123 .It Fl r Ar repository-path
124 Use the repository at the specified path.
125 If not specified, assume the repository is located at or above the current
126 working directory.
127 .It Fl I Ar pattern
128 Ignore files or directories with a name which matches the specified
129 .Ar pattern .
130 This option may be specified multiple times to build a list of ignore patterns.
131 The
132 .Ar pattern
133 follows the globbing rules documented in
134 .Xr glob 7 .
135 .El
136 .It Cm im
137 Short alias for
138 .Cm import .
139 .It Cm clone Oo Fl a Oc Oo Fl b Ar branch Oc Oo Fl l Oc Oo Fl m Oc Oo Fl q Oc Oo Fl v Oc Oo Fl R Ar reference Oc Ar repository-URL Op Ar directory
140 Clone a Git repository at the specified
141 .Ar repository-URL
142 into the specified
143 .Ar directory .
144 If no
145 .Ar directory
146 is specified the directory name will be derived from the name of the
147 cloned repository.
148 .Cm got clone
149 will refuse to run if the
150 .Ar directory
151 already exists.
152 .Pp
153 The
154 .Ar repository-URL
155 specifies a protocol scheme, a server hostname, an optional port number
156 separated from the hostname by a colon, and a path to the repository on
157 the server:
158 .Lk scheme://hostname:port/path/to/repository
159 .Pp
160 The following protocol schemes are supported:
161 .Bl -tag -width git+ssh
162 .It git
163 The Git protocol as implemented by the
164 .Xr git-daemon 1
165 server.
166 Use of this protocol is discouraged since it supports neither authentication
167 nor encryption.
168 .It git+ssh
169 The Git protocol wrapped in an authenticated and encrypted
170 .Xr ssh 1
171 tunnel.
172 With this protocol the hostname may contain an embedded username for
173 .Xr ssh 1
174 to use:
175 .Mt user@hostname
176 .It ssh
177 Short alias for git+ssh.
178 .El
179 .Pp
180 Objects in the cloned repository are stored in a pack file which is downloaded
181 from the server.
182 This pack file will then be indexed to facilitate access to the objects stored
183 within.
184 If any objects in the pack file are stored in deltified form, all deltas will
185 be fully resolved in order to compute the ID of such objects.
186 This can take some time.
187 More details about the pack file format are documented in
188 .Xr git-repository 5 .
189 .Pp
190 .Cm got clone
191 creates a remote repository entry in the
192 .Pa config
193 file of the cloned repository to store the
194 .Ar repository-url
195 for future use by
196 .Cm got fetch
197 or
198 .Xr git-fetch 1 .
199 .Pp
200 The options for
201 .Cm got clone
202 are as follows:
203 .Bl -tag -width Ds
204 .It Fl a
205 Fetch all branches from the remote repository's
206 .Dq refs/heads/
207 reference namespace.
208 If this option is not specified, a branch resolved via the remote
209 repository's HEAD reference will be fetched.
210 Cannot be used together with the
211 .Fl b
212 option.
213 .It Fl b Ar branch
214 Fetch the specified
215 .Ar branch
216 from the remote repository's
217 .Dq refs/heads/
218 reference namespace.
219 This option may be specified multiple times to build a list of branches
220 to fetch.
221 If the branch corresponding to the remote repository's HEAD reference is not
222 in this list, the cloned repository's HEAD reference will be set to the first
223 branch which was fetched.
224 If this option is not specified, a branch resolved via the remote
225 repository's HEAD reference will be fetched.
226 Cannot be used together with the
227 .Fl a
228 option.
229 .It Fl l
230 List branches and tags available for fetching from the remote repository
231 and exit immediately.
232 Cannot be used together with any of the other options except
233 .Fl v .
234 .It Fl m
235 Create the cloned repository as a mirror of the original repository.
236 This is useful if the cloned repository will not be used to store
237 local changes as created by
238 .Cm got commit .
239 .Pp
240 The repository's
241 .Pa config
242 file will be set up with the
243 .Dq mirror
244 option enabled, such that
245 .Cm got fetch
246 or
247 .Xr git-fetch 1
248 will write incoming changes directly to local branches in the
249 .Dq refs/heads/
250 reference namespace, rather than to branches in the
251 .Dq refs/remotes/
252 namespace.
253 This avoids the usual requirement of having to run
254 .Cm got rebase
255 after
256 .Cm got fetch
257 in order to make incoming changes appear on local branches.
258 But maintaining local changes in the cloned repository becomes difficult
259 since local changes will be at risk of being discarded whenever incoming
260 changes are fetched.
261 .It Fl q
262 Suppress progress reporting output.
263 The same option will be passed to
264 .Xr ssh 1
265 if applicable.
266 .It Fl v
267 Verbose mode.
268 Causes
269 .Cm got clone
270 to print debugging messages to standard error output.
271 This option will be passed to
272 .Xr ssh 1
273 if applicable.
274 Multiple -v options increase the verbosity.
275 The maximum is 3.
276 .It Fl R Ar reference
277 In addition to the branches and tags that will be fetched, fetch an arbitrary
278 .Ar reference
279 from the remote repository's
280 .Dq refs/
281 namespace.
282 This option may be specified multiple times to build a list of additional
283 references to fetch.
284 The specified
285 .Ar reference
286 may either be a path to a specific reference, or a reference namespace
287 which will cause all references in this namespace to be fetched.
288 .Pp
289 Each reference will be mapped into the cloned repository's
290 .Dq refs/remotes/
291 namespace, unless the
292 .Fl m
293 option is used to mirror references directly into the cloned repository's
294 .Dq refs/
295 namespace.
296 .Pp
297 .Cm got clone
298 will refuse to fetch references from the remote repository's
299 .Dq refs/remotes/
300 or
301 .Dq refs/got/
302 namespace.
303 .El
304 .It Cm cl
305 Short alias for
306 .Cm clone .
307 .It Cm fetch Oo Fl a Oc Oo Fl b Ar branch Oc Oo Fl d Oc Oo Fl l Oc Oo Fl r Ar repository-path Oc Oo Fl t Oc Oo Fl q Oc Oo Fl v Oc Oo Fl R Ar reference Oc Op Ar remote-repository
308 Fetch new changes from a remote repository.
309 If no
310 .Ar remote-repository
311 is specified,
312 .Dq origin
313 will be used.
314 The remote repository's URL is obtained from the corresponding entry in the
315 .Pa config
316 file of the local repository, as created by
317 .Cm got clone .
318 .Pp
319 New changes will be stored in a separate pack file downloaded from the server.
320 Optionally, separate pack files stored in the repository can be combined with
321 .Xr git-repack 1 .
322 .Pp
323 By default, branch references in the
324 .Dq refs/remotes/
325 reference namespace will be updated to point at the newly fetched commits.
326 The
327 .Cm got rebase
328 command can then be used to make new changes visible on local branches in the
329 .Dq refs/heads/
330 namespace, merging incoming changes with local changes as necessary.
331 .Pp
332 If the repository was created as a mirror with
333 .Cm got clone -m
334 then all branches in the
335 .Dq refs/heads/
336 namespace will be updated directly to match the corresponding branches in
337 the remote repository.
338 If those branches contained local commits, these commits will no longer be
339 reachable via a reference and will therefore be at risk of being discarded
340 by Git's garbage collector.
341 Maintaining local changes in a mirror repository is therefore discouraged.
342 .Pp
343 In any case, references in the
344 .Dq refs/tags/
345 namespace will always be fetched and mapped directly to local references
346 in the same namespace.
347 .Pp
348 The options for
349 .Cm got fetch
350 are as follows:
351 .Bl -tag -width Ds
352 .It Fl a
353 Fetch all branches from the remote repository's
354 .Dq refs/heads/
355 reference namespace.
356 If this option is not specified, a branch resolved via the remote
357 repository's HEAD reference will be fetched.
358 Cannot be used together with the
359 .Fl b
360 option.
361 .It Fl b Ar branch
362 Fetch the specified
363 .Ar branch
364 from the remote repository's
365 .Dq refs/heads/
366 reference namespace.
367 This option may be specified multiple times to build a list of branches
368 to fetch.
369 If this option is not specified, a branch resolved via the remote
370 repository's HEAD reference will be fetched.
371 Cannot be used together with the
372 .Fl a
373 option.
374 .It Fl d
375 Delete branches and tags from the local repository which are no longer
376 present in the remote repository.
377 Only references are deleted.
378 Any commit, tree, tag, and blob objects belonging to deleted branches or
379 tags remain in the repository and may be removed separately with
380 Git's garbage collector.
381 .It Fl l
382 List branches and tags available for fetching from the remote repository
383 and exit immediately.
384 Cannot be used together with any of the other options except
385 .Fl v
386 and
387 .Fl r .
388 .It Fl t
389 Allow existing references in the
390 .Dq refs/tags
391 namespace to be updated if they have changed on the server.
392 If not specified, only new tag references will be created.
393 .It Fl r Ar repository-path
394 Use the repository at the specified path.
395 If not specified, assume the repository is located at or above the current
396 working directory.
397 If this directory is a
398 .Nm
399 work tree, use the repository path associated with this work tree.
400 .It Fl q
401 Suppress progress reporting output.
402 The same option will be passed to
403 .Xr ssh 1
404 if applicable.
405 .It Fl v
406 Verbose mode.
407 Causes
408 .Cm got fetch
409 to print debugging messages to standard error output.
410 The same option will be passed to
411 .Xr ssh 1
412 if applicable.
413 Multiple -v options increase the verbosity.
414 The maximum is 3.
415 .It Fl R Ar reference
416 In addition to the branches and tags that will be fetched, fetch an arbitrary
417 .Ar reference
418 from the remote repository's
419 .Dq refs/
420 namespace.
421 This option may be specified multiple times to build a list of additional
422 references to fetch.
423 The specified
424 .Ar reference
425 may either be a path to a specific reference, or a reference namespace
426 which will cause all references in this namespace to be fetched.
427 .Pp
428 Each reference will be mapped into the local repository's
429 .Dq refs/remotes/
430 namespace, unless the local repository was created as a mirror with
431 .Cm got clone -m
432 in which case references will be mapped directly into the local repository's
433 .Dq refs/
434 namespace.
435 .Pp
436 Once a reference has been fetched, a local branch based on it can be
437 created with
438 .Cm got branch
439 if needed.
440 .Pp
441 .Cm got fetch
442 will refuse to fetch references from the remote repository's
443 .Dq refs/remotes/
444 or
445 .Dq refs/got/
446 namespace.
447 .El
448 .It Cm fe
449 Short alias for
450 .Cm fetch .
451 .It Cm checkout Oo Fl E Oc Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Oo Fl p Ar path-prefix Oc Ar repository-path Op Ar work-tree-path
452 Copy files from a repository into a new work tree.
453 Show the status of each affected file, using the following status codes:
454 .Bl -column YXZ description
455 .It A Ta new file was added
456 .It E Ta file already exists in work tree's meta-data
457 .El
458 .Pp
459 If the
460 .Ar work tree path
461 is not specified, either use the last component of
462 .Ar repository path ,
463 or if a
464 .Ar path prefix
465 was specified use the last component of
466 .Ar path prefix .
467 .Pp
468 The options for
469 .Cm got checkout
470 are as follows:
471 .Bl -tag -width Ds
472 .It Fl E
473 Proceed with the checkout operation even if the directory at
474 .Ar work-tree-path
475 is not empty.
476 Existing files will be left intact.
477 .It Fl b Ar branch
478 Check out files from a commit on the specified
479 .Ar branch .
480 If this option is not specified, a branch resolved via the repository's HEAD
481 reference will be used.
482 .It Fl c Ar commit
483 Check out files from the specified
484 .Ar commit
485 on the selected branch.
486 The expected argument is a commit ID SHA1 hash or an existing reference
487 or tag name which will be resolved to a commit ID.
488 An abbreviated hash argument will be expanded to a full SHA1 hash
489 automatically, provided the abbreviation is unique.
490 If this option is not specified, the most recent commit on the selected
491 branch will be used.
492 .Pp
493 If the specified
494 .Ar commit
495 is not contained in the selected branch, a different branch which contains
496 this commit must be specified with the
497 .Fl b
498 option.
499 If no such branch is known a new branch must be created for this
500 commit with
501 .Cm got branch
502 before
503 .Cm got checkout
504 can be used.
505 Checking out work trees with an unknown branch is intentionally not supported.
506 .It Fl p Ar path-prefix
507 Restrict the work tree to a subset of the repository's tree hierarchy.
508 Only files beneath the specified
509 .Ar path-prefix
510 will be checked out.
511 .El
512 .It Cm co
513 Short alias for
514 .Cm checkout .
515 .It Cm update Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Op Ar path ...
516 Update an existing work tree to a different commit.
517 Show the status of each affected file, using the following status codes:
518 .Bl -column YXZ description
519 .It U Ta file was updated and contained no local changes
520 .It G Ta file was updated and local changes were merged cleanly
521 .It C Ta file was updated and conflicts occurred during merge
522 .It D Ta file was deleted
523 .It A Ta new file was added
524 .It \(a~ Ta versioned file is obstructed by a non-regular file
525 .It ! Ta a missing versioned file was restored
526 .El
527 .Pp
528 If no
529 .Ar path
530 is specified, update the entire work tree.
531 Otherwise, restrict the update operation to files at or within the
532 specified paths.
533 Each path is required to exist in the update operation's target commit.
534 Files in the work tree outside specified paths will remain unchanged and
535 will retain their previously recorded base commit.
536 Some
537 .Nm
538 commands may refuse to run while the work tree contains files from
539 multiple base commits.
540 The base commit of such a work tree can be made consistent by running
541 .Cm got update
542 across the entire work tree.
543 Specifying a
544 .Ar path
545 is incompatible with the
546 .Fl b
547 option.
548 .Pp
549 .Cm got update
550 cannot update paths with staged changes.
551 If changes have been staged with
552 .Cm got stage ,
553 these changes must first be committed with
554 .Cm got commit
555 or unstaged with
556 .Cm got unstage .
557 .Pp
558 The options for
559 .Cm got update
560 are as follows:
561 .Bl -tag -width Ds
562 .It Fl b Ar branch
563 Switch the work tree's branch reference to the specified
564 .Ar branch
565 before updating the work tree.
566 This option requires that all paths in the work tree are updated.
567 .It Fl c Ar commit
568 Update the work tree to the specified
569 .Ar commit .
570 The expected argument is a commit ID SHA1 hash or an existing reference
571 or tag name which will be resolved to a commit ID.
572 An abbreviated hash argument will be expanded to a full SHA1 hash
573 automatically, provided the abbreviation is unique.
574 If this option is not specified, the most recent commit on the work tree's
575 branch will be used.
576 .El
577 .It Cm up
578 Short alias for
579 .Cm update .
580 .It Cm status Op Ar path ...
581 Show the current modification status of files in a work tree,
582 using the following status codes:
583 .Bl -column YXZ description
584 .It M Ta modified file
585 .It A Ta file scheduled for addition in next commit
586 .It D Ta file scheduled for deletion in next commit
587 .It C Ta modified or added file which contains merge conflicts
588 .It ! Ta versioned file was expected on disk but is missing
589 .It \(a~ Ta versioned file is obstructed by a non-regular file
590 .It ? Ta unversioned item not tracked by
591 .Nm
592 .It m Ta modified file modes (executable bit only)
593 .It N Ta non-existent
594 .Ar path
595 specified on the command line
596 .El
597 .Pp
598 If no
599 .Ar path
600 is specified, show modifications in the entire work tree.
601 Otherwise, show modifications at or within the specified paths.
602 .Pp
603 If changes have been staged with
604 .Cm got stage ,
605 staged changes are shown in the second output column, using the following
606 status codes:
607 .Bl -column YXZ description
608 .It M Ta file modification is staged
609 .It A Ta file addition is staged
610 .It D Ta file deletion is staged
611 .El
612 .Pp
613 Changes created on top of staged changes are indicated in the first column:
614 .Bl -column YXZ description
615 .It MM Ta file was modified after earlier changes have been staged
616 .It MA Ta file was modified after having been staged for addition
617 .El
618 .Pp
619 For compatibility with
620 .Xr cvs 1
621 and
622 .Xr git 1 ,
623 .Cm got status
624 reads
625 .Xr glob 7
626 patterns from
627 .Pa .cvsignore
628 and
629 .Pa .gitignore
630 files in each traversed directory and will not display unversioned files
631 which match these patterns.
632 As an extension to
633 .Xr glob 7
634 matching rules,
635 .Cm got status
636 supports consecutive asterisks,
637 .Dq ** ,
638 which will match an arbitrary amount of directories.
639 Unlike
640 .Xr cvs 1 ,
641 .Cm got status
642 only supports a single ignore pattern per line.
643 Unlike
644 .Xr git 1 ,
645 .Cm got status
646 does not support negated ignore patterns prefixed with
647 .Dq \&! ,
648 and gives no special significance to the location of path component separators,
649 .Dq / ,
650 in a pattern.
651 .It Cm st
652 Short alias for
653 .Cm status .
654 .It Cm log Oo Fl b Oc Oo Fl c Ar commit Oc Oo Fl C Ar number Oc Oo Fl l Ar N Oc Oo Fl p Oc Oo Fl s Ar search-pattern Oc Oo Fl r Ar repository-path Oc Op Ar path
655 Display history of a repository.
656 If a
657 .Ar path
658 is specified, show only commits which modified this path.
659 If invoked in a work tree, the
660 .Ar path
661 is interpreted relative to the current working directory,
662 and the work tree's path prefix is implicitly prepended.
663 Otherwise, the path is interpreted relative to the repository root.
664 .Pp
665 The options for
666 .Cm got log
667 are as follows:
668 .Bl -tag -width Ds
669 .It Fl b
670 Display individual commits which were merged into the current branch
671 from other branches.
672 By default,
673 .Cm got log
674 shows the linear history of the current branch only.
675 .It Fl c Ar commit
676 Start traversing history at the specified
677 .Ar commit .
678 The expected argument is a commit ID SHA1 hash or an existing reference
679 or tag name which will be resolved to a commit ID.
680 An abbreviated hash argument will be expanded to a full SHA1 hash
681 automatically, provided the abbreviation is unique.
682 If this option is not specified, default to the work tree's current branch
683 if invoked in a work tree, or to the repository's HEAD reference.
684 .It Fl C Ar number
685 Set the number of context lines shown in diffs with
686 .Fl p .
687 By default, 3 lines of context are shown.
688 .It Fl l Ar N
689 Limit history traversal to a given number of commits.
690 If this option is not specified, a default limit value of zero is used,
691 which is treated as an unbounded limit.
692 The
693 .Ev GOT_LOG_DEFAULT_LIMIT
694 environment variable may be set to change this default value.
695 .It Fl p
696 Display the patch of modifications made in each commit.
697 If a
698 .Ar path
699 is specified, only show the patch of modifications at or within this path.
700 .It Fl s Ar search-pattern
701 If specified, show only commits with a log message matched by the extended
702 regular expression
703 .Ar search-pattern .
704 Regular expression syntax is documented in
705 .Xr re_format 7 .
706 .It Fl r Ar repository-path
707 Use the repository at the specified path.
708 If not specified, assume the repository is located at or above the current
709 working directory.
710 If this directory is a
711 .Nm
712 work tree, use the repository path associated with this work tree.
713 .El
714 .It Cm diff Oo Fl C Ar number Oc Oo Fl r Ar repository-path Oc Oo Fl s Oc Oo Fl w Oc Op Ar object1 Ar object2 | Ar path
715 When invoked within a work tree with less than two arguments, display
716 uncommitted changes in the work tree.
717 If a
718 .Ar path
719 is specified, only show changes within this path.
720 .Pp
721 If two arguments are provided, treat each argument as a reference, a tag
722 name, or an object ID SHA1 hash, and display differences between the
723 corresponding objects.
724 Both objects must be of the same type (blobs, trees, or commits).
725 An abbreviated hash argument will be expanded to a full SHA1 hash
726 automatically, provided the abbreviation is unique.
727 .Pp
728 The options for
729 .Cm got diff
730 are as follows:
731 .Bl -tag -width Ds
732 .It Fl C Ar number
733 Set the number of context lines shown in the diff.
734 By default, 3 lines of context are shown.
735 .It Fl r Ar repository-path
736 Use the repository at the specified path.
737 If not specified, assume the repository is located at or above the current
738 working directory.
739 If this directory is a
740 .Nm
741 work tree, use the repository path associated with this work tree.
742 .It Fl s
743 Show changes staged with
744 .Cm got stage
745 instead of showing local changes.
746 This option is only valid when
747 .Cm got diff
748 is invoked in a work tree.
749 .It Fl w
750 Ignore whitespace-only changes.
751 .El
752 .It Cm di
753 Short alias for
754 .Cm diff .
755 .It Cm blame Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Ar path
756 Display line-by-line history of a file at the specified path.
757 .Pp
758 The options for
759 .Cm got blame
760 are as follows:
761 .Bl -tag -width Ds
762 .It Fl c Ar commit
763 Start traversing history at the specified
764 .Ar commit .
765 The expected argument is a commit ID SHA1 hash or an existing reference
766 or tag name which will be resolved to a commit ID.
767 An abbreviated hash argument will be expanded to a full SHA1 hash
768 automatically, provided the abbreviation is unique.
769 .It Fl r Ar repository-path
770 Use the repository at the specified path.
771 If not specified, assume the repository is located at or above the current
772 working directory.
773 If this directory is a
774 .Nm
775 work tree, use the repository path associated with this work tree.
776 .El
777 .It Cm bl
778 Short alias for
779 .Cm blame .
780 .It Cm tree Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Oo Fl i Oc Oo Fl R Oc Op Ar path
781 Display a listing of files and directories at the specified
782 directory path in the repository.
783 Entries shown in this listing may carry one of the following trailing
784 annotations:
785 .Bl -column YXZ description
786 .It @ Ta entry is a symbolic link
787 .It / Ta entry is a directory
788 .It * Ta entry is an executable file
789 .It $ Ta entry is a Git submodule
790 .El
791 .Pp
792 If no
793 .Ar path
794 is specified, list the repository path corresponding to the current
795 directory of the work tree, or the root directory of the repository
796 if there is no work tree.
797 .Pp
798 The options for
799 .Cm got tree
800 are as follows:
801 .Bl -tag -width Ds
802 .It Fl c Ar commit
803 List files and directories as they appear in the specified
804 .Ar commit .
805 The expected argument is a commit ID SHA1 hash or an existing reference
806 or tag name which will be resolved to a commit ID.
807 An abbreviated hash argument will be expanded to a full SHA1 hash
808 automatically, provided the abbreviation is unique.
809 .It Fl r Ar repository-path
810 Use the repository at the specified path.
811 If not specified, assume the repository is located at or above the current
812 working directory.
813 If this directory is a
814 .Nm
815 work tree, use the repository path associated with this work tree.
816 .It Fl i
817 Show object IDs of files (blob objects) and directories (tree objects).
818 .It Fl R
819 Recurse into sub-directories in the repository.
820 .El
821 .It Cm tr
822 Short alias for
823 .Cm tree .
824 .It Cm ref Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl d Ar name Oc Oo Fl s Oc Op Ar name Ar target
825 Manage references in a repository.
826 .Pp
827 If no options are passed, expect two arguments and attempt to create,
828 or update, the reference with the given
829 .Ar name ,
830 and make it point at the given
831 .Ar target .
832 The name must be an absolute reference name, i.e. it must begin with
833 .Dq refs/ .
834 The target may be an object ID SHA1 hash or an existing reference which
835 will be resolved to an object ID.
836 An abbreviated hash argument will be expanded to a full SHA1 hash
837 automatically, provided the abbreviation is unique.
838 .Pp
839 The options for
840 .Cm got ref
841 are as follows:
842 .Bl -tag -width Ds
843 .It Fl r Ar repository-path
844 Use the repository at the specified path.
845 If not specified, assume the repository is located at or above the current
846 working directory.
847 If this directory is a
848 .Nm
849 work tree, use the repository path associated with this work tree.
850 .It Fl l
851 List all existing references in the repository.
852 .It Fl d Ar name
853 Delete the reference with the specified name from the repository.
854 .It Fl s
855 Create a symbolic reference pointing at the specified
856 .Ar target ,
857 which must be an existing reference.
858 Care should be taken not to create loops between references when
859 this option is used.
860 .El
861 .It Cm branch Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl d Ar name Oc Oo Fl n Oc Op Ar name
862 Create, list, or delete branches.
863 .Pp
864 Branches are managed via references which live in the
865 .Dq refs/heads/
866 reference namespace.
867 The
868 .Cm got branch
869 command operates on references in this namespace only.
870 .Pp
871 If invoked in a work tree without any arguments, print the name of the
872 work tree's current branch.
873 .Pp
874 If a
875 .Ar name
876 argument is passed, attempt to create a branch reference with the given name.
877 By default the new branch reference will point at the latest commit on the
878 work tree's current branch if invoked in a work tree, and otherwise to a commit
879 resolved via the repository's HEAD reference.
880 .Pp
881 If invoked in a work tree, once the branch was created successfully
882 switch the work tree's head reference to the newly created branch and
883 update files across the entire work tree, just like
884 .Cm got update -b Ar name
885 would do.
886 Show the status of each affected file, using the following status codes:
887 .Bl -column YXZ description
888 .It U Ta file was updated and contained no local changes
889 .It G Ta file was updated and local changes were merged cleanly
890 .It C Ta file was updated and conflicts occurred during merge
891 .It D Ta file was deleted
892 .It A Ta new file was added
893 .It \(a~ Ta versioned file is obstructed by a non-regular file
894 .It ! Ta a missing versioned file was restored
895 .El
896 .Pp
897 The options for
898 .Cm got branch
899 are as follows:
900 .Bl -tag -width Ds
901 .It Fl c Ar commit
902 Make a newly created branch reference point at the specified
903 .Ar commit .
904 The expected
905 .Ar commit
906 argument is a commit ID SHA1 hash or an existing reference
907 or tag name which will be resolved to a commit ID.
908 .It Fl r Ar repository-path
909 Use the repository at the specified path.
910 If not specified, assume the repository is located at or above the current
911 working directory.
912 If this directory is a
913 .Nm
914 work tree, use the repository path associated with this work tree.
915 .It Fl l
916 List all existing branches in the repository.
917 If invoked in a work tree, the work tree's current branch is shown
918 with one the following annotations:
919 .Bl -column YXZ description
920 .It * Ta work tree's base commit matches the branch tip
921 .It \(a~ Ta work tree's base commit is out-of-date
922 .El
923 .It Fl d Ar name
924 Delete the branch with the specified name from the repository.
925 Only the branch reference is deleted.
926 Any commit, tree, and blob objects belonging to the branch
927 remain in the repository and may be removed separately with
928 Git's garbage collector.
929 .It Fl n
930 Do not switch and update the work tree after creating a new branch.
931 .El
932 .It Cm br
933 Short alias for
934 .Cm branch .
935 .It Cm tag Oo Fl c Ar commit Oc Oo Fl m Ar message Oc Oo Fl r Ar repository-path Oc Oo Fl l Oc Ar name
936 Manage tags in a repository.
937 .Pp
938 Tags are managed via references which live in the
939 .Dq refs/tags/
940 reference namespace.
941 The
942 .Cm got tag
943 command operates on references in this namespace only.
944 References in this namespace point at tag objects which contain a pointer
945 to another object, a tag message, as well as author and timestamp information.
946 .Pp
947 Attempt to create a tag with the given
948 .Ar name ,
949 and make this tag point at the given
950 .Ar commit .
951 If no commit is specified, default to the latest commit on the work tree's
952 current branch if invoked in a work tree, and to a commit resolved via
953 the repository's HEAD reference otherwise.
954 .Pp
955 The options for
956 .Cm got tag
957 are as follows:
958 .Bl -tag -width Ds
959 .It Fl c Ar commit
960 Make the newly created tag reference point at the specified
961 .Ar commit .
962 The expected
963 .Ar commit
964 argument is a commit ID SHA1 hash or an existing reference or tag name which
965 will be resolved to a commit ID.
966 An abbreviated hash argument will be expanded to a full SHA1 hash
967 automatically, provided the abbreviation is unique.
968 .It Fl m Ar message
969 Use the specified tag message when creating the new tag.
970 Without the
971 .Fl m
972 option,
973 .Cm got tag
974 opens a temporary file in an editor where a tag message can be written.
975 .It Fl r Ar repository-path
976 Use the repository at the specified path.
977 If not specified, assume the repository is located at or above the current
978 working directory.
979 If this directory is a
980 .Nm
981 work tree, use the repository path associated with this work tree.
982 .It Fl l
983 List all existing tags in the repository instead of creating a new tag.
984 If this option is used, no other command-line arguments are allowed.
985 .El
986 .Pp
987 By design, the
988 .Cm got tag
989 command will not delete tags or change existing tags.
990 If a tag must be deleted, the
991 .Cm got ref
992 command may be used to delete a tag's reference.
993 This should only be done if the tag has not already been copied to
994 another repository.
995 .It Cm add Oo Fl R Oc Oo Fl I Oc Ar path ...
996 Schedule unversioned files in a work tree for addition to the
997 repository in the next commit.
998 .Pp
999 The options for
1000 .Cm got add
1001 are as follows:
1002 .Bl -tag -width Ds
1003 .It Fl R
1004 Permit recursion into directories.
1005 If this option is not specified,
1006 .Cm got add
1007 will refuse to run if a specified
1008 .Ar path
1009 is a directory.
1010 .It Fl I
1011 With -R, add files even if they match a
1012 .Cm got status
1013 ignore pattern.
1014 .El
1015 .It Cm remove Oo Fl f Oc Oo Fl k Oc Oo Fl R Oc Ar path ...
1016 Remove versioned files from a work tree and schedule them for deletion
1017 from the repository in the next commit.
1018 .Pp
1019 The options for
1020 .Cm got remove
1021 are as follows:
1022 .Bl -tag -width Ds
1023 .It Fl f
1024 Perform the operation even if a file contains uncommitted modifications.
1025 .It Fl k
1026 Keep affected files on disk.
1027 .It Fl R
1028 Permit recursion into directories.
1029 If this option is not specified,
1030 .Cm got remove
1031 will refuse to run if a specified
1032 .Ar path
1033 is a directory.
1034 .El
1035 .It Cm rm
1036 Short alias for
1037 .Cm remove .
1038 .It Cm revert Oo Fl p Oc Oo Fl F Ar response-script Oc Oo Fl R Oc Ar path ...
1039 Revert any uncommitted changes in files at the specified paths.
1040 File contents will be overwritten with those contained in the
1041 work tree's base commit.
1042 There is no way to bring discarded changes back after
1043 .Cm got revert !
1044 .Pp
1045 If a file was added with
1046 .Cm got add
1047 it will become an unversioned file again.
1048 If a file was deleted with
1049 .Cm got remove
1050 it will be restored.
1051 .Pp
1052 The options for
1053 .Cm got revert
1054 are as follows:
1055 .Bl -tag -width Ds
1056 .It Fl p
1057 Instead of reverting all changes in files, interactively select or reject
1058 changes to revert based on
1059 .Dq y
1060 (revert change),
1061 .Dq n
1062 (keep change), and
1063 .Dq q
1064 (quit reverting this file) responses.
1065 If a file is in modified status, individual patches derived from the
1066 modified file content can be reverted.
1067 Files in added or deleted status may only be reverted in their entirety.
1068 .It Fl F Ar response-script
1069 With the
1070 .Fl p
1071 option, read
1072 .Dq y ,
1073 .Dq n ,
1074 and
1075 .Dq q
1076 responses line-by-line from the specified
1077 .Ar response-script
1078 file instead of prompting interactively.
1079 .It Fl R
1080 Permit recursion into directories.
1081 If this option is not specified,
1082 .Cm got revert
1083 will refuse to run if a specified
1084 .Ar path
1085 is a directory.
1086 .El
1087 .It Cm rv
1088 Short alias for
1089 .Cm revert .
1090 .It Cm commit Oo Fl m Ar message Oc Op Ar path ...
1091 Create a new commit in the repository from changes in a work tree
1092 and use this commit as the new base commit for the work tree.
1093 If no
1094 .Ar path
1095 is specified, commit all changes in the work tree.
1096 Otherwise, commit changes at or within the specified paths.
1097 .Pp
1098 If changes have been explicitly staged for commit with
1099 .Cm got stage ,
1100 only commit staged changes and reject any specified paths which
1101 have not been staged.
1102 .Pp
1103 Show the status of each affected file, using the following status codes:
1104 .Bl -column YXZ description
1105 .It M Ta modified file
1106 .It D Ta file was deleted
1107 .It A Ta new file was added
1108 .It m Ta modified file modes (executable bit only)
1109 .El
1110 .Pp
1111 Files which are not part of the new commit will retain their previously
1112 recorded base commit.
1113 Some
1114 .Nm
1115 commands may refuse to run while the work tree contains files from
1116 multiple base commits.
1117 The base commit of such a work tree can be made consistent by running
1118 .Cm got update
1119 across the entire work tree.
1120 .Pp
1121 The
1122 .Cm got commit
1123 command requires the
1124 .Ev GOT_AUTHOR
1125 environment variable to be set,
1126 unless Git's
1127 .Dv user.name
1128 and
1129 .Dv user.email
1130 configuration settings can be
1131 obtained from the repository's
1132 .Pa .git/config
1133 file or from Git's global
1134 .Pa ~/.gitconfig
1135 configuration file.
1136 .Pp
1137 The options for
1138 .Cm got commit
1139 are as follows:
1140 .Bl -tag -width Ds
1141 .It Fl m Ar message
1142 Use the specified log message when creating the new commit.
1143 Without the
1144 .Fl m
1145 option,
1146 .Cm got commit
1147 opens a temporary file in an editor where a log message can be written.
1148 .El
1149 .Pp
1150 .Cm got commit
1151 will refuse to run if certain preconditions are not met.
1152 If the work tree's current branch is not in the
1153 .Dq refs/heads/
1154 reference namespace, new commits may not be created on this branch.
1155 Local changes may only be committed if they are based on file content
1156 found in the most recent commit on the work tree's branch.
1157 If a path is found to be out of date,
1158 .Cm got update
1159 must be used first in order to merge local changes with changes made
1160 in the repository.
1161 .It Cm ci
1162 Short alias for
1163 .Cm commit .
1164 .It Cm cherrypick Ar commit
1165 Merge changes from a single
1166 .Ar commit
1167 into the work tree.
1168 The specified
1169 .Ar commit
1170 must be on a different branch than the work tree's base commit.
1171 The expected argument is a reference or a commit ID SHA1 hash.
1172 An abbreviated hash argument will be expanded to a full SHA1 hash
1173 automatically, provided the abbreviation is unique.
1174 .Pp
1175 Show the status of each affected file, using the following status codes:
1176 .Bl -column YXZ description
1177 .It G Ta file was merged
1178 .It C Ta file was merged and conflicts occurred during merge
1179 .It ! Ta changes destined for a missing file were not merged
1180 .It D Ta file was deleted
1181 .It d Ta file's deletion was obstructed by local modifications
1182 .It A Ta new file was added
1183 .It \(a~ Ta changes destined for a non-regular file were not merged
1184 .El
1185 .Pp
1186 The merged changes will appear as local changes in the work tree, which
1187 may be viewed with
1188 .Cm got diff ,
1189 amended manually or with further
1190 .Cm got cherrypick
1191 commands,
1192 committed with
1193 .Cm got commit ,
1194 or discarded again with
1195 .Cm got revert .
1196 .Pp
1197 .Cm got cherrypick
1198 will refuse to run if certain preconditions are not met.
1199 If the work tree contains multiple base commits it must first be updated
1200 to a single base commit with
1201 .Cm got update .
1202 If the work tree already contains files with merge conflicts, these
1203 conflicts must be resolved first.
1204 .It Cm cy
1205 Short alias for
1206 .Cm cherrypick .
1207 .It Cm backout Ar commit
1208 Reverse-merge changes from a single
1209 .Ar commit
1210 into the work tree.
1211 The specified
1212 .Ar commit
1213 must be on the same branch as the work tree's base commit.
1214 The expected argument is a reference or a commit ID SHA1 hash.
1215 An abbreviated hash argument will be expanded to a full SHA1 hash
1216 automatically, provided the abbreviation is unique.
1217 .Pp
1218 Show the status of each affected file, using the following status codes:
1219 .Bl -column YXZ description
1220 .It G Ta file was merged
1221 .It C Ta file was merged and conflicts occurred during merge
1222 .It ! Ta changes destined for a missing file were not merged
1223 .It D Ta file was deleted
1224 .It d Ta file's deletion was obstructed by local modifications
1225 .It A Ta new file was added
1226 .It \(a~ Ta changes destined for a non-regular file were not merged
1227 .El
1228 .Pp
1229 The reverse-merged changes will appear as local changes in the work tree,
1230 which may be viewed with
1231 .Cm got diff ,
1232 amended manually or with further
1233 .Cm got backout
1234 commands,
1235 committed with
1236 .Cm got commit ,
1237 or discarded again with
1238 .Cm got revert .
1239 .Pp
1240 .Cm got backout
1241 will refuse to run if certain preconditions are not met.
1242 If the work tree contains multiple base commits it must first be updated
1243 to a single base commit with
1244 .Cm got update .
1245 If the work tree already contains files with merge conflicts, these
1246 conflicts must be resolved first.
1247 .It Cm bo
1248 Short alias for
1249 .Cm backout .
1250 .It Cm rebase Oo Fl a Oc Oo Fl c Oc Op Ar branch
1251 Rebase commits on the specified
1252 .Ar branch
1253 onto the tip of the current branch of the work tree.
1254 The
1255 .Ar branch
1256 must share common ancestry with the work tree's current branch.
1257 Rebasing begins with the first descendant commit of the youngest
1258 common ancestor commit shared by the specified
1259 .Ar branch
1260 and the work tree's current branch, and stops once the tip commit
1261 of the specified
1262 .Ar branch
1263 has been rebased.
1264 .Pp
1265 When
1266 .Cm got rebase
1267 is used as intended, the specified
1268 .Ar branch
1269 represents a local commit history and may already contain changes
1270 that are not yet visible in any other repositories.
1271 The work tree's current branch, which must be set with
1272 .Cm got update -b
1273 before starting the
1274 .Cm rebase
1275 operation, represents a branch from a remote repository which shares
1276 a common history with the specified
1277 .Ar branch
1278 but has progressed, and perhaps diverged, due to commits added to the
1279 remote repository.
1280 .Pp
1281 Rebased commits are accumulated on a temporary branch which the work tree
1282 will remain switched to throughout the entire rebase operation.
1283 Commits on this branch represent the same changes with the same log
1284 messages as their counterparts on the original
1285 .Ar branch ,
1286 but with different commit IDs.
1287 Once rebasing has completed successfully, the temporary branch becomes
1288 the new version of the specified
1289 .Ar branch
1290 and the work tree is automatically switched to it.
1291 .Pp
1292 While rebasing commits, show the status of each affected file,
1293 using the following status codes:
1294 .Bl -column YXZ description
1295 .It G Ta file was merged
1296 .It C Ta file was merged and conflicts occurred during merge
1297 .It ! Ta changes destined for a missing file were not merged
1298 .It D Ta file was deleted
1299 .It d Ta file's deletion was obstructed by local modifications
1300 .It A Ta new file was added
1301 .It \(a~ Ta changes destined for a non-regular file were not merged
1302 .El
1303 .Pp
1304 If merge conflicts occur the rebase operation is interrupted and may
1305 be continued once conflicts have been resolved.
1306 Alternatively, the rebase operation may be aborted which will leave
1307 .Ar branch
1308 unmodified and the work tree switched back to its original branch.
1309 .Pp
1310 If a merge conflict is resolved in a way which renders the merged
1311 change into a no-op change, the corresponding commit will be elided
1312 when the rebase operation continues.
1313 .Pp
1314 .Cm got rebase
1315 will refuse to run if certain preconditions are not met.
1316 If the work tree is not yet fully updated to the tip commit of its
1317 branch then the work tree must first be updated with
1318 .Cm got update .
1319 If changes have been staged with
1320 .Cm got stage ,
1321 these changes must first be committed with
1322 .Cm got commit
1323 or unstaged with
1324 .Cm got unstage .
1325 If the work tree contains local changes, these changes must first be
1326 committed with
1327 .Cm got commit
1328 or reverted with
1329 .Cm got revert .
1330 If the
1331 .Ar branch
1332 contains changes to files outside of the work tree's path prefix,
1333 the work tree cannot be used to rebase this branch.
1334 .Pp
1335 The
1336 .Cm got update
1337 and
1338 .Cm got commit
1339 commands will refuse to run while a rebase operation is in progress.
1340 Other commands which manipulate the work tree may be used for
1341 conflict resolution purposes.
1342 .Pp
1343 The options for
1344 .Cm got rebase
1345 are as follows:
1346 .Bl -tag -width Ds
1347 .It Fl a
1348 Abort an interrupted rebase operation.
1349 If this option is used, no other command-line arguments are allowed.
1350 .It Fl c
1351 Continue an interrupted rebase operation.
1352 If this option is used, no other command-line arguments are allowed.
1353 .El
1354 .It Cm rb
1355 Short alias for
1356 .Cm rebase .
1357 .It Cm histedit Oo Fl a Oc Oo Fl c Oc Oo Fl F Ar histedit-script Oc Oo Fl m Oc
1358 Edit commit history between the work tree's current base commit and
1359 the tip commit of the work tree's current branch.
1360 .Pp
1361 Before starting a
1362 .Cm histedit
1363 operation the work tree's current branch must be set with
1364 .Cm got update -b
1365 to the branch which should be edited, unless this branch is already the
1366 current branch of the work tree.
1367 The tip of this branch represents the upper bound (inclusive) of commits
1368 touched by the
1369 .Cm histedit
1370 operation.
1371 .Pp
1372 Furthermore, the work tree's base commit
1373 must be set with
1374 .Cm got update -c
1375 to a point in this branch's commit history where editing should begin.
1376 This commit represents the lower bound (non-inclusive) of commits touched
1377 by the
1378 .Cm histedit
1379 operation.
1380 .Pp
1381 Editing of commit history is controlled via a
1382 .Ar histedit script
1383 which can be written in an editor based on a template, passed on the
1384 command line, or generated with the
1385 .Fl m
1386 option if only log messages need to be edited.
1387 .Pp
1388 The format of the histedit script is line-based.
1389 Each line in the script begins with a command name, followed by
1390 whitespace and an argument.
1391 For most commands, the expected argument is a commit ID SHA1 hash.
1392 Any remaining text on the line is ignored.
1393 Lines which begin with the
1394 .Sq #
1395 character are ignored entirely.
1396 .Pp
1397 The available commands are as follows:
1398 .Bl -column YXZ pick-commit
1399 .It pick Ar commit Ta Use the specified commit as it is.
1400 .It edit Ar commit Ta Use the specified commit but once changes have been
1401 merged into the work tree interrupt the histedit operation for amending.
1402 .It fold Ar commit Ta Combine the specified commit with the next commit
1403 listed further below that will be used.
1404 .It drop Ar commit Ta Remove this commit from the edited history.
1405 .It mesg Ar log-message Ta Use the specified single-line log message for
1406 the commit on the previous line.
1407 If the log message argument is left empty, open an editor where a new
1408 log message can be written.
1409 .El
1410 .Pp
1411 Every commit in the history being edited must be mentioned in the script.
1412 Lines may be re-ordered to change the order of commits in the edited history.
1413 No commit may be listed more than once.
1414 .Pp
1415 Edited commits are accumulated on a temporary branch which the work tree
1416 will remain switched to throughout the entire histedit operation.
1417 Once history editing has completed successfully, the temporary branch becomes
1418 the new version of the work tree's branch and the work tree is automatically
1419 switched to it.
1420 .Pp
1421 While merging commits, show the status of each affected file,
1422 using the following status codes:
1423 .Bl -column YXZ description
1424 .It G Ta file was merged
1425 .It C Ta file was merged and conflicts occurred during merge
1426 .It ! Ta changes destined for a missing file were not merged
1427 .It D Ta file was deleted
1428 .It d Ta file's deletion was obstructed by local modifications
1429 .It A Ta new file was added
1430 .It \(a~ Ta changes destined for a non-regular file were not merged
1431 .El
1432 .Pp
1433 If merge conflicts occur the histedit operation is interrupted and may
1434 be continued once conflicts have been resolved.
1435 Alternatively, the histedit operation may be aborted which will leave
1436 the work tree switched back to its original branch.
1437 .Pp
1438 If a merge conflict is resolved in a way which renders the merged
1439 change into a no-op change, the corresponding commit will be elided
1440 when the histedit operation continues.
1441 .Pp
1442 .Cm got histedit
1443 will refuse to run if certain preconditions are not met.
1444 If the work tree's current branch is not in the
1445 .Dq refs/heads/
1446 reference namespace, the history of the branch may not be edited.
1447 If the work tree contains multiple base commits it must first be updated
1448 to a single base commit with
1449 .Cm got update .
1450 If changes have been staged with
1451 .Cm got stage ,
1452 these changes must first be committed with
1453 .Cm got commit
1454 or unstaged with
1455 .Cm got unstage .
1456 If the work tree contains local changes, these changes must first be
1457 committed with
1458 .Cm got commit
1459 or reverted with
1460 .Cm got revert .
1461 If the edited history contains changes to files outside of the work tree's
1462 path prefix, the work tree cannot be used to edit the history of this branch.
1463 .Pp
1464 The
1465 .Cm got update ,
1466 .Cm got rebase ,
1467 and
1468 .Cm got integrate
1469 commands will refuse to run while a histedit operation is in progress.
1470 Other commands which manipulate the work tree may be used, and the
1471 .Cm got commit
1472 command may be used to commit arbitrary changes to the temporary branch
1473 while the histedit operation is interrupted.
1474 .Pp
1475 The options for
1476 .Cm got histedit
1477 are as follows:
1478 .Bl -tag -width Ds
1479 .It Fl a
1480 Abort an interrupted histedit operation.
1481 If this option is used, no other command-line arguments are allowed.
1482 .It Fl c
1483 Continue an interrupted histedit operation.
1484 If this option is used, no other command-line arguments are allowed.
1485 .It Fl F Ar histedit-script
1486 Use the specified
1487 .Ar histedit-script
1488 instead of opening a temporary file in an editor where a histedit script
1489 can be written.
1490 .It Fl m
1491 Edit log messages only.
1492 This option is a quick equivalent to a histedit script which edits
1493 only log messages but otherwise leaves every picked commit as-is.
1494 The
1495 .Fl m
1496 option can only be used when starting a new histedit operation.
1497 If this option is used, no other command-line arguments are allowed.
1498 .El
1499 .It Cm he
1500 Short alias for
1501 .Cm histedit .
1502 .It Cm integrate Ar branch
1503 Integrate the specified
1504 .Ar branch
1505 into the work tree's current branch.
1506 Files in the work tree are updated to match the contents on the integrated
1507 .Ar branch ,
1508 and the reference of the work tree's branch is changed to point at the
1509 head commit of the integrated
1510 .Ar branch .
1511 .Pp
1512 Both branches can be considered equivalent after integration since they
1513 will be pointing at the same commit.
1514 Both branches remain available for future work, if desired.
1515 In case the integrated
1516 .Ar branch
1517 is no longer needed it may be deleted with
1518 .Cm got branch -d .
1519 .Pp
1520 Show the status of each affected file, using the following status codes:
1521 .Bl -column YXZ description
1522 .It U Ta file was updated
1523 .It D Ta file was deleted
1524 .It A Ta new file was added
1525 .It \(a~ Ta versioned file is obstructed by a non-regular file
1526 .It ! Ta a missing versioned file was restored
1527 .El
1528 .Pp
1529 .Cm got integrate
1530 will refuse to run if certain preconditions are not met.
1531 Most importantly, the
1532 .Ar branch
1533 must have been rebased onto the work tree's current branch with
1534 .Cm got rebase
1535 before it can be integrated, in order to linearize commit history and
1536 resolve merge conflicts.
1537 If the work tree contains multiple base commits it must first be updated
1538 to a single base commit with
1539 .Cm got update .
1540 If changes have been staged with
1541 .Cm got stage ,
1542 these changes must first be committed with
1543 .Cm got commit
1544 or unstaged with
1545 .Cm got unstage .
1546 If the work tree contains local changes, these changes must first be
1547 committed with
1548 .Cm got commit
1549 or reverted with
1550 .Cm got revert .
1551 .It Cm ig
1552 Short alias for
1553 .Cm integrate .
1554 .It Cm stage Oo Fl l Oc Oo Fl p Oc Oo Fl F Ar response-script Oc Op Ar path ...
1555 Stage local changes for inclusion in the next commit.
1556 If no
1557 .Ar path
1558 is specified, stage all changes in the work tree.
1559 Otherwise, stage changes at or within the specified paths.
1560 Paths may be staged if they are added, modified, or deleted according to
1561 .Cm got status .
1562 .Pp
1563 Show the status of each affected file, using the following status codes:
1564 .Bl -column YXZ description
1565 .It A Ta file addition has been staged
1566 .It M Ta file modification has been staged
1567 .It D Ta file deletion has been staged
1568 .El
1569 .Pp
1570 Staged file contents are saved in newly created blob objects in the repository.
1571 These blobs will be referred to by tree objects once staged changes have been
1572 committed.
1573 .Pp
1574 Staged changes affect the behaviour of
1575 .Cm got commit ,
1576 .Cm got status ,
1577 and
1578 .Cm got diff .
1579 While paths with staged changes exist, the
1580 .Cm got commit
1581 command will refuse to commit any paths which do not have staged changes.
1582 Local changes created on top of staged changes can only be committed if
1583 the path is staged again, or if the staged changes are committed first.
1584 The
1585 .Cm got status
1586 command will show both local changes and staged changes.
1587 The
1588 .Cm got diff
1589 command is able to display local changes relative to staged changes,
1590 and to display staged changes relative to the repository.
1591 The
1592 .Cm got revert
1593 command cannot revert staged changes but may be used to revert
1594 local changes created on top of staged changes.
1595 .Pp
1596 The options for
1597 .Cm got stage
1598 are as follows:
1599 .Bl -tag -width Ds
1600 .It Fl l
1601 Instead of staging new changes, list paths which are already staged,
1602 along with the IDs of staged blob objects and stage status codes.
1603 If paths were provided in the command line show the staged paths
1604 among the specified paths.
1605 Otherwise, show all staged paths.
1606 .It Fl p
1607 Instead of staging the entire content of a changed file, interactively
1608 select or reject changes for staging based on
1609 .Dq y
1610 (stage change),
1611 .Dq n
1612 (reject change), and
1613 .Dq q
1614 (quit staging this file) responses.
1615 If a file is in modified status, individual patches derived from the
1616 modified file content can be staged.
1617 Files in added or deleted status may only be staged or rejected in
1618 their entirety.
1619 .It Fl F Ar response-script
1620 With the
1621 .Fl p
1622 option, read
1623 .Dq y ,
1624 .Dq n ,
1625 and
1626 .Dq q
1627 responses line-by-line from the specified
1628 .Ar response-script
1629 file instead of prompting interactively.
1630 .El
1631 .Pp
1632 .Cm got stage
1633 will refuse to run if certain preconditions are not met.
1634 If a file contains merge conflicts, these conflicts must be resolved first.
1635 If a file is found to be out of date relative to the head commit on the
1636 work tree's current branch, the file must be updated with
1637 .Cm got update
1638 before it can be staged (however, this does not prevent the file from
1639 becoming out-of-date at some point after having been staged).
1640 .Pp
1641 The
1642 .Cm got update ,
1643 .Cm got rebase ,
1644 and
1645 .Cm got histedit
1646 commands will refuse to run while staged changes exist.
1647 If staged changes cannot be committed because a staged path
1648 is out of date, the path must be unstaged with
1649 .Cm got unstage
1650 before it can be updated with
1651 .Cm got update ,
1652 and may then be staged again if necessary.
1653 .It Cm sg
1654 Short alias for
1655 .Cm stage .
1656 .It Cm unstage Oo Fl p Oc Oo Fl F Ar response-script Oc Op Ar path ...
1657 Merge staged changes back into the work tree and put affected paths
1658 back into non-staged status.
1659 If no
1660 .Ar path
1661 is specified, unstage all staged changes across the entire work tree.
1662 Otherwise, unstage changes at or within the specified paths.
1663 .Pp
1664 Show the status of each affected file, using the following status codes:
1665 .Bl -column YXZ description
1666 .It G Ta file was unstaged
1667 .It C Ta file was unstaged and conflicts occurred during merge
1668 .It ! Ta changes destined for a missing file were not merged
1669 .It D Ta file was staged as deleted and still is deleted
1670 .It d Ta file's deletion was obstructed by local modifications
1671 .It \(a~ Ta changes destined for a non-regular file were not merged
1672 .El
1673 .Pp
1674 The options for
1675 .Cm got unstage
1676 are as follows:
1677 .Bl -tag -width Ds
1678 .It Fl p
1679 Instead of unstaging the entire content of a changed file, interactively
1680 select or reject changes for unstaging based on
1681 .Dq y
1682 (unstage change),
1683 .Dq n
1684 (keep change staged), and
1685 .Dq q
1686 (quit unstaging this file) responses.
1687 If a file is staged in modified status, individual patches derived from the
1688 staged file content can be unstaged.
1689 Files staged in added or deleted status may only be unstaged in their entirety.
1690 .It Fl F Ar response-script
1691 With the
1692 .Fl p
1693 option, read
1694 .Dq y ,
1695 .Dq n ,
1696 and
1697 .Dq q
1698 responses line-by-line from the specified
1699 .Ar response-script
1700 file instead of prompting interactively.
1701 .El
1702 .It Cm ug
1703 Short alias for
1704 .Cm unstage .
1705 .It Cm cat Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Oo Fl P Oc Ar arg ...
1706 Parse and print contents of objects to standard output in a line-based
1707 text format.
1708 Content of commit, tree, and tag objects is printed in a way similar
1709 to the actual content stored in such objects.
1710 Blob object contents are printed as they would appear in files on disk.
1711 .Pp
1712 Attempt to interpret each argument as a reference, a tag name, or
1713 an object ID SHA1 hash.
1714 References will be resolved to an object ID.
1715 Tag names will resolved to a tag object.
1716 An abbreviated hash argument will be expanded to a full SHA1 hash
1717 automatically, provided the abbreviation is unique.
1718 .Pp
1719 If none of the above interpretations produce a valid result, or if the
1720 .Fl P
1721 option is used, attempt to interpret the argument as a path which will
1722 be resolved to the ID of an object found at this path in the repository.
1723 .Pp
1724 The options for
1725 .Cm got cat
1726 are as follows:
1727 .Bl -tag -width Ds
1728 .It Fl c Ar commit
1729 Look up paths in the specified
1730 .Ar commit .
1731 If this option is not used, paths are looked up in the commit resolved
1732 via the repository's HEAD reference.
1733 The expected argument is a commit ID SHA1 hash or an existing reference
1734 or tag name which will be resolved to a commit ID.
1735 An abbreviated hash argument will be expanded to a full SHA1 hash
1736 automatically, provided the abbreviation is unique.
1737 .It Fl r Ar repository-path
1738 Use the repository at the specified path.
1739 If not specified, assume the repository is located at or above the current
1740 working directory.
1741 If this directory is a
1742 .Nm
1743 work tree, use the repository path associated with this work tree.
1744 .It Fl P
1745 Interpret all arguments as paths only.
1746 This option can be used to resolve ambiguity in cases where paths
1747 look like tag names, reference names, or object IDs.
1748 .El
1749 .El
1750 .Sh ENVIRONMENT
1751 .Bl -tag -width GOT_AUTHOR
1752 .It Ev GOT_AUTHOR
1753 The author's name and email address for
1754 .Cm got commit
1755 and
1756 .Cm got import ,
1757 for example:
1758 .Dq An Flan Hacker Aq Mt flan_hacker@openbsd.org .
1759 Because
1760 .Xr git 1
1761 may fail to parse commits without an email address in author data,
1762 .Nm
1763 attempts to reject
1764 .Ev GOT_AUTHOR
1765 environment variables with a missing email address.
1766 .Pp
1767 If present, Git's
1768 .Dv user.name
1769 and
1770 .Dv user.email
1771 configuration settings in the repository's
1772 .Pa .git/config
1773 file will override the value of
1774 .Ev GOT_AUTHOR .
1775 However, the
1776 .Dv user.name
1777 and
1778 .Dv user.email
1779 configuration settings contained in Git's global
1780 .Pa ~/.gitconfig
1781 configuration file will be used only if the
1782 .Ev GOT_AUTHOR
1783 environment variable is
1784 .Em not
1785 set.
1786 .It Ev VISUAL , EDITOR
1787 The editor spawned by
1788 .Cm got commit ,
1789 .Cm got import ,
1791 .Cm got tag .
1792 .It Ev GOT_LOG_DEFAULT_LIMIT
1793 The default limit on the number of commits traversed by
1794 .Cm got log .
1795 If set to zero, the limit is unbounded.
1796 This variable will be silently ignored if it is set to a non-numeric value.
1797 .El
1798 .Sh EXIT STATUS
1799 .Ex -std got
1800 .Sh EXAMPLES
1801 Clone an existing Git repository for use with
1802 .Nm .
1803 .Pp
1804 .Dl $ cd /var/git/
1805 .Dl $ got clone ssh://git@github.com/openbsd/src.git
1806 .Pp
1807 Use of HTTP URLs currently requires
1808 .Xr git 1 :
1809 .Pp
1810 .Dl $ cd /var/git/
1811 .Dl $ git clone --bare https://github.com/openbsd/src.git
1812 .Pp
1813 Alternatively, for quick and dirty local testing of
1814 .Nm
1815 a new Git repository could be created and populated with files,
1816 e.g. from a temporary CVS checkout located at
1817 .Pa /tmp/src :
1818 .Pp
1819 .Dl $ got init /var/git/src.git
1820 .Dl $ got import -r /var/git/src.git -I CVS -I obj /tmp/src
1821 .Pp
1822 Check out a work tree from the Git repository to /usr/src:
1823 .Pp
1824 .Dl $ got checkout /var/git/src.git /usr/src
1825 .Pp
1826 View local changes in a work tree directory:
1827 .Pp
1828 .Dl $ got status
1829 .Dl $ got diff | less
1830 .Pp
1831 Interactively revert selected local changes in a work tree directory:
1832 .Pp
1833 .Dl $ got revert -p -R\ .
1834 .Pp
1835 In a work tree or a git repository directory, list all branch references:
1836 .Pp
1837 .Dl $ got branch -l
1838 .Pp
1839 In a work tree or a git repository directory, create a new branch called
1840 .Dq unified-buffer-cache
1841 which is forked off the
1842 .Dq master
1843 branch:
1844 .Pp
1845 .Dl $ got branch unified-buffer-cache master
1846 .Pp
1847 Switch an existing work tree to the branch
1848 .Dq unified-buffer-cache .
1849 Local changes in the work tree will be preserved and merged if necessary:
1850 .Pp
1851 .Dl $ got update -b unified-buffer-cache
1852 .Pp
1853 Create a new commit from local changes in a work tree directory.
1854 This new commit will become the head commit of the work tree's current branch:
1855 .Pp
1856 .Dl $ got commit
1857 .Pp
1858 In a work tree or a git repository directory, view changes committed in
1859 the 3 most recent commits to the work tree's branch, or the branch resolved
1860 via the repository's HEAD reference, respectively:
1861 .Pp
1862 .Dl $ got log -p -l 3
1863 .Pp
1864 In a work tree or a git repository directory, log the history of a subdirectory:
1865 .Pp
1866 .Dl $ got log sys/uvm
1867 .Pp
1868 While operating inside a work tree, paths are specified relative to the current
1869 working directory, so this command will log the subdirectory
1870 .Pa sys/uvm :
1871 .Pp
1872 .Dl $ cd sys/uvm && got log '.'
1873 .Pp
1874 And this command has the same effect:
1875 .Pp
1876 .Dl $ cd sys/dev/usb && got log ../../uvm
1877 .Pp
1878 Add new files and remove obsolete files in a work tree directory:
1879 .Pp
1880 .Dl $ got add sys/uvm/uvm_ubc.c
1881 .Dl $ got remove sys/uvm/uvm_vnode.c
1882 .Pp
1883 Create a new commit from local changes in a work tree directory
1884 with a pre-defined log message.
1885 .Pp
1886 .Dl $ got commit -m 'unify the buffer cache'
1887 .Pp
1888 Update any work tree checked out from the
1889 .Dq unified-buffer-cache
1890 branch to the latest commit on this branch:
1891 .Pp
1892 .Dl $ got update
1893 .Pp
1894 Roll file content on the unified-buffer-cache branch back by one commit,
1895 and then fetch the rolled-back change into the work tree as a local change
1896 to be amended and perhaps committed again:
1897 .Pp
1898 .Dl $ got backout unified-buffer-cache
1899 .Dl $ got commit -m 'roll back previous'
1900 .Dl $ # now back out the previous backout :-)
1901 .Dl $ got backout unified-buffer-cache
1902 .Pp
1903 Fetch new upstream commits into the local repository's
1904 .Dq origin/master
1905 branch:
1906 .Pp
1907 .Dl $ cd /usr/src
1908 .Dl $ got fetch
1909 .Pp
1910 In a repository created with a HTTP URL and
1911 .Cm git clone --bare
1912 the
1913 .Xr git-fetch 1
1914 command must be used instead:
1915 .Pp
1916 .Dl $ cd /var/git/src.git
1917 .Dl $ git fetch origin master:refs/remotes/origin/master
1918 .Pp
1919 Rebase the local
1920 .Dq master
1921 branch to merge the new changes that are now visible on the
1922 .Dq origin/master
1923 branch:
1924 .Pp
1925 .Dl $ cd /usr/src
1926 .Dl $ got update -b origin/master
1927 .Dl $ got rebase master
1928 .Pp
1929 Rebase the
1930 .Dq unified-buffer-cache
1931 branch on top of the new head commit of the
1932 .Dq master
1933 branch.
1934 .Pp
1935 .Dl $ got update -b master
1936 .Dl $ got rebase unified-buffer-cache
1937 .Pp
1938 Create a patch from all changes on the unified-buffer-cache branch.
1939 The patch can be mailed out for review and applied to
1940 .Ox Ns 's
1941 CVS tree:
1942 .Pp
1943 .Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff
1944 .Pp
1945 Edit the entire commit history of the
1946 .Dq unified-buffer-cache
1947 branch:
1948 .Pp
1949 .Dl $ got update -b unified-buffer-cache
1950 .Dl $ got update -c master
1951 .Dl $ got histedit
1952 .Pp
1953 In order to merge changes committed to the
1954 .Dq unified-buffer-cache
1955 branch back into the
1956 .Dq master
1957 branch, the
1958 .Dq unified-buffer-cache
1959 branch must first be rebased onto the
1960 .Dq master
1961 branch:
1962 .Pp
1963 .Dl $ got update -b master
1964 .Dl $ got rebase unified-buffer-cache
1965 .Pp
1966 Changes on the
1967 .Dq unified-buffer-cache
1968 branch can now be made visible on the
1969 .Dq master
1970 branch with
1971 .Cm got integrate .
1972 Because the rebase operation switched the work tree to the
1973 .Dq unified-buffer-cache
1974 branch, the work tree must be switched back to the
1975 .Dq master
1976 branch before the
1977 .Dq unified-buffer-cache
1978 branch can be integrated into
1979 .Dq master :
1980 .Pp
1981 .Dl $ got update -b master
1982 .Dl $ got integrate unified-buffer-cache
1983 .Pp
1984 Additional steps may be necessary if local changes need to be pushed back
1985 to the remote repository, which currently requires
1986 .Cm git push .
1987 Before working against existing branches in a repository cloned with
1988 .Cm git clone --bare
1989 instead of
1990 .Cm got clone ,
1991 a Git
1992 .Dq refspec
1993 must be configured to map all references in the remote repository
1994 into the
1995 .Dq refs/remotes
1996 namespace of the local repository.
1997 This can achieved by setting Git's
1998 .Pa remote.origin.fetch
1999 configuration variable to the value
2000 .Dq +refs/heads/*:refs/remotes/origin/*
2001 with the
2002 .Cm git config
2003 command:
2004 .Pp
2005 .Dl $ cd /var/git/repo
2006 .Dl $ git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
2007 Additionally, the
2008 .Dq mirror
2009 option must be disabled:
2010 .Pp
2011 .Dl $ cd /var/git/repo
2012 .Dl $ git config remote.origin.mirror false
2013 .Pp
2014 Alternatively, the following
2015 .Xr git-fetch 1
2016 configuration item can be added manually to the Git repository's
2017 .Pa config
2018 file:
2019 .Pp
2020 .Dl [remote "origin"]
2021 .Dl url = ...
2022 .Dl fetch = +refs/heads/*:refs/remotes/origin/*
2023 .Dl mirror = false
2024 .Pp
2025 This configuration leaves the local repository's
2026 .Dq refs/heads
2027 namespace free for use by local branches checked out with
2028 .Cm got checkout
2029 and, if needed, created with
2030 .Cm got branch .
2031 .Pp
2032 Branches in the
2033 .Dq remotes/origin
2034 namespace can now be updated with incoming changes from the remote
2035 repository with
2036 .Cm got fetch
2038 .Xr git-fetch 1
2039 without extra command line arguments:
2040 .Pp
2041 .Dl $ cd /var/git/repo
2042 .Dl $ git fetch
2043 .Pp
2044 To make changes fetched from the remote repository appear on the
2045 .Dq master
2046 branch, the
2047 .Dq master
2048 branch must be rebased onto the
2049 .Dq origin/master
2050 branch.
2051 This will also merge local changes, if any, with the incoming changes:
2052 .Pp
2053 .Dl $ got update -b origin/master
2054 .Dl $ got rebase master
2055 .Pp
2056 On the
2057 .Dq master
2058 branch, log messages for local changes can now be amended with
2059 .Dq OK
2060 by other developers and any other important new information:
2061 .Pp
2062 .Dl $ got update -c origin/master
2063 .Dl $ got histedit -m
2064 .Pp
2065 Local changes on the
2066 .Dq master
2067 branch can then be pushed to the remote
2068 repository with
2069 .Cm git push :
2070 .Pp
2071 .Dl $ cd /var/git/repo
2072 .Dl $ git push origin master
2073 .Sh SEE ALSO
2074 .Xr tog 1 ,
2075 .Xr git-repository 5 ,
2076 .Xr got-worktree 5
2077 .Sh AUTHORS
2078 .An Stefan Sperling Aq Mt stsp@openbsd.org
2079 .An Martin Pieuchot Aq Mt mpi@openbsd.org
2080 .An Joshua Stein Aq Mt jcs@openbsd.org
2081 .An Ori Bernstein Aq Mt ori@openbsd.org
2082 .Sh CAVEATS
2083 .Nm
2084 is a work-in-progress and many commands remain to be implemented.
2085 At present, the user has to fall back on
2086 .Xr git 1
2087 to perform many tasks, in particular tasks related to repository
2088 administration and tasks which require a network connection.