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