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