Blob


1 .\"
2 .\" Copyright (c) 2017 Martin Pieuchot
3 .\" Copyright (c) 2018, 2019 Stefan Sperling
4 .\"
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
8 .\"
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\"
17 .Dd $Mdocdate$
18 .Dt GOT 1
19 .Os
20 .Sh NAME
21 .Nm got
22 .Nd game of trees
23 .Sh SYNOPSIS
24 .Nm
25 .Ar command
26 .Op Fl h
27 .Op Ar arg ...
28 .Sh DESCRIPTION
29 .Nm
30 is a version control system which stores the history of tracked files
31 in a Git repository, as used by the Git version control system.
32 This repository format is described in
33 .Xr git-repository 5 .
34 .Pp
35 .Nm
36 is a
37 .Dq distributed
38 version control system because every copy of a repository is writeable.
39 Modifications made to files can be synchronized between repositories
40 at any time.
41 .Pp
42 Files managed by
43 .Nm
44 must be checked out from the repository for modification.
45 Checked out files are stored in a
46 .Em work tree
47 which can be placed at an arbitrary directory in the filesystem hierarchy.
48 The on-disk format of this work tree is described in
49 .Xr got-worktree 5 .
50 .Pp
51 .Nm
52 provides global and command-specific options.
53 Global options must preceed the command name, and are as follows:
54 .Bl -tag -width tenletters
55 .It Fl h
56 Display usage information.
57 .El
58 .Pp
59 The commands for
60 .Nm
61 are as follows:
62 .Bl -tag -width checkout
63 .It Cm init Ar path
64 Create a new empty repository at the specified
65 .Ar path .
66 .It Cm checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
67 Copy files from a repository into a new work tree.
68 If the
69 .Ar work tree path
70 is not specified, either use the last component of
71 .Ar repository path ,
72 or if a
73 .Ar path prefix
74 was specified use the last component of
75 .Ar path prefix .
76 .Pp
77 The options for
78 .Cm got checkout
79 are as follows:
80 .Bl -tag -width Ds
81 .It Fl b Ar branch
82 Check out files from the specified
83 .Ar branch .
84 If this option is not specified, a branch resolved via the repository's HEAD
85 reference will be used.
86 .It Fl c Ar commit
87 Check out files from the specified
88 .Ar commit .
89 If this option is not specified, the most recent commit on the selected
90 branch will be used.
91 .It Fl p Ar path-prefix
92 Restrict the work tree to a subset of the repository's tree hierarchy.
93 Only files beneath the specified
94 .Ar path-prefix
95 will be checked out.
96 .El
97 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
98 Update an existing work tree to a different commit.
99 Show the status of each affected file, using the following status codes:
100 .Bl -column YXZ description
101 .It U Ta file was updated and contained no local changes
102 .It G Ta file was updated and local changes were merged cleanly
103 .It C Ta file was updated and conflicts occurred during merge
104 .It D Ta file was deleted
105 .It A Ta new file was added
106 .It ~ Ta versioned file is obstructed by a non-regular file
107 .It ! Ta a missing versioned file was restored
108 .El
109 .Pp
110 If a
111 .Ar path
112 is specified, restrict the update operation to files at or within this path.
113 The path is required to exist in the update operation's target commit.
114 Files in the work tree outside this path will remain unchanged and will
115 retain their previously recorded base commit.
116 Some
117 .Nm
118 commands may refuse to run while the work tree contains files from
119 multiple base commits.
120 The base commit of such a work tree can be made consistent by running
121 .Cm got update
122 across the entire work tree.
123 Specifying a
124 .Ar path
125 is incompatible with the
126 .Fl b
127 option.
128 .Pp
129 The options for
130 .Cm got update
131 are as follows:
132 .Bl -tag -width Ds
133 .It Fl b Ar branch
134 Switch the work tree's branch reference to the specified
135 .Ar branch
136 before updating the work tree.
137 This option requires that all paths in the work tree are updated.
138 .It Fl c Ar commit
139 Update the work tree to the specified
140 .Ar commit .
141 The expected argument is a SHA1 hash which corresponds to a commit object.
142 If this option is not specified, the most recent commit on the work tree's
143 branch will be used.
144 .El
145 .It Cm status [ Ar path ]
146 Show the current modification status of files in a work tree,
147 using the following status codes:
148 .Bl -column YXZ description
149 .It M Ta modified file
150 .It A Ta file scheduled for addition in next commit
151 .It D Ta file scheduled for deletion in next commit
152 .It C Ta modified or added file which contains merge conflicts
153 .It ! Ta versioned file was expected on disk but is missing
154 .It ~ Ta versioned file is obstructed by a non-regular file
155 .It ? Ta unversioned item not tracked by
156 .Nm
157 .El
158 .Pp
159 If a
160 .Ar path
161 is specified, only show modifications within this path.
162 .It Cm log [ Fl b ] [ Fl c Ar commit ] [ Fl C Ar number ] [ Fl l Ar N ] [ Fl p ] [ Fl r Ar repository-path ] [ path ]
163 Display history of a repository.
164 If a
165 .Ar path
166 is specified, show only commits which modified this path.
167 .Pp
168 The options for
169 .Cm got log
170 are as follows:
171 .Bl -tag -width Ds
172 .It Fl b
173 Show the linear line of history of the current branch.
174 This option restricts history traversal to the first parent of each commit.
175 Commits which the branch was based on and merge commits which affected the
176 branch will be shown, but individual commits created on parallel branches
177 will be omitted.
178 .It Fl c Ar commit
179 Start traversing history at the specified
180 .Ar commit .
181 The expected argument is the name of a branch or a SHA1 hash which corresponds
182 to a commit object.
183 If this option is not specified, default to the work tree's current branch
184 if invoked in a work tree, or to the repository's HEAD reference.
185 .It Fl C Ar number
186 Set the number of context lines shown in diffs with
187 .Fl p .
188 By default, 3 lines of context are shown.
189 .It Fl l Ar N
190 Limit history traversal to a given number of commits.
191 .It Fl p
192 Display the patch of modifications made in each commit.
193 .It Fl r Ar repository-path
194 Use the repository at the specified path.
195 If not specified, assume the repository is located at or above the current
196 working directory.
197 If this directory is a
198 .Nm
199 work tree, use the repository path associated with this work tree.
200 .El
201 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
202 When invoked within a work tree with less than two arguments, display
203 uncommitted changes in the work tree.
204 If a
205 .Ar path
206 is specified, only show changes within this path.
207 .Pp
208 If two arguments are provided, treat each argument as a reference,
209 or a SHA1 hash, which corresponds to an object in the repository,
210 and display differences between these objects.
211 Both objects must be of the same type (blobs, trees, or commits).
212 .Pp
213 The options for
214 .Cm got diff
215 are as follows:
216 .Bl -tag -width Ds
217 .It Fl C Ar number
218 Set the number of context lines shown in the diff.
219 By default, 3 lines of context are shown.
220 .It Fl r Ar repository-path
221 Use the repository at the specified path.
222 If not specified, assume the repository is located at or above the current
223 working directory.
224 If this directory is a
225 .Nm
226 work tree, use the repository path associated with this work tree.
227 .El
228 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
229 Display line-by-line history of a file at the specified path.
230 .Pp
231 The options for
232 .Cm got blame
233 are as follows:
234 .Bl -tag -width Ds
235 .It Fl c Ar commit
236 Start traversing history at the specified
237 .Ar commit .
238 The expected argument is the name of a branch or a SHA1 hash which corresponds
239 to a commit object.
240 .It Fl r Ar repository-path
241 Use the repository at the specified path.
242 If not specified, assume the repository is located at or above the current
243 working directory.
244 If this directory is a
245 .Nm
246 work tree, use the repository path associated with this work tree.
247 .El
248 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
249 Display a listing of files and directories at the specified
250 directory path in the repository.
251 Entries shown in this listing may carry one of the following trailing
252 annotations:
253 .Bl -column YXZ description
254 .It / Ta entry is a directory
255 .It * Ta entry is an executable file
256 .El
257 .Pp
258 If no
259 .Ar path
260 is specified, list the repository path corresponding to the current
261 directory of the work tree, or the root directory of the repository
262 if there is no work tree.
263 .Pp
264 The options for
265 .Cm got tree
266 are as follows:
267 .Bl -tag -width Ds
268 .It Fl c Ar commit
269 List files and directories as they appear in the specified
270 .Ar commit .
271 The expected argument is the name of a branch or a SHA1 hash which corresponds
272 to a commit object.
273 .It Fl r Ar repository-path
274 Use the repository at the specified path.
275 If not specified, assume the repository is located at or above the current
276 working directory.
277 If this directory is a
278 .Nm
279 work tree, use the repository path associated with this work tree.
280 .It Fl i
281 Show object IDs of files (blob objects) and directories (tree objects).
282 .It Fl R
283 Recurse into sub-directories in the repository.
284 .El
285 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
286 Manage references in a repository.
287 .Pp
288 If no options are passed, expect two arguments and attempt to create,
289 or update, the reference with the given
290 .Ar name ,
291 and make it point at the given
292 .Ar target .
293 The target may be a SHA1 hash which corresponds to an existing object ID
294 in the repository, or an existing reference which will be resolved to an
295 object ID.
296 .Pp
297 The options for
298 .Cm got ref
299 are as follows:
300 .Bl -tag -width Ds
301 .It Fl r Ar repository-path
302 Use the repository at the specified path.
303 If not specified, assume the repository is located at or above the current
304 working directory.
305 If this directory is a
306 .Nm
307 work tree, use the repository path associated with this work tree.
308 .It Fl l
309 List all existing references in the repository.
310 .It Fl d Ar name
311 Delete the reference with the specified name from the repository.
312 .El
313 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
314 Manage branches in a repository.
315 .Pp
316 Branches are managed via references which live in the
317 .Dq refs/heads/
318 reference namespace.
319 The
320 .Cm got branch
321 command operates on references in this namespace only.
322 .Pp
323 If no options are passed, expect one or two arguments and attempt to create
324 a branch with the given
325 .Ar name ,
326 and make it point at the given
327 .Ar base-branch .
328 If no
329 .Ar base-branch
330 is specified, default to the work tree's current branch if invoked in a
331 work tree, or to the repository's HEAD reference.
332 .Pp
333 The options for
334 .Cm got branch
335 are as follows:
336 .Bl -tag -width Ds
337 .It Fl r Ar repository-path
338 Use the repository at the specified path.
339 If not specified, assume the repository is located at or above the current
340 working directory.
341 If this directory is a
342 .Nm
343 work tree, use the repository path associated with this work tree.
344 .It Fl l
345 List all existing branches in the repository.
346 .It Fl d Ar name
347 Delete the branch with the specified name from the repository.
348 .El
349 .It Cm add Ar file-path ...
350 Schedule unversioned files in a work tree for addition to the
351 repository in the next commit.
352 .It Cm rm Ar file-path ...
353 Remove versioned files from a work tree and schedule them for deletion
354 from the repository in the next commit.
355 .Pp
356 The options for
357 .Cm got rm
358 are as follows:
359 .Bl -tag -width Ds
360 .It Fl f
361 Perform the operation even if a file contains uncommitted modifications.
362 .El
363 .It Cm revert Ar file-path ...
364 Revert any uncommited changes in files at the specified paths.
365 File contents will be overwritten with those contained in the
366 work tree's base commit. There is no way to bring discarded
367 changes back after
368 .Cm got revert !
369 .Pp
370 If a file was added with
371 .Cm got add
372 it will become an unversioned file again.
373 If a file was deleted with
374 .Cm got rm
375 it will be restored.
376 .It Cm commit [ Fl m Ar msg ] [ file-path ]
377 Create a new commit in the repository from local changes in a work tree
378 and use this commit as the new base commit for the work tree.
379 .Pp
380 Show the status of each affected file, using the following status codes:
381 .Bl -column YXZ description
382 .It M Ta modified file
383 .It D Ta file was deleted
384 .It A Ta new file was added
385 .El
386 .Pp
387 Files without local changes will retain their previously recorded base
388 commit.
389 Some
390 .Nm
391 commands may refuse to run while the work tree contains files from
392 multiple base commits.
393 The base commit of such a work tree can be made consistent by running
394 .Cm got update
395 across the entire work tree.
396 .Pp
397 The
398 .Cm got commit
399 command requires the
400 .Ev GOT_AUTHOR
401 environment variable to be set.
402 .Pp
403 The options for
404 .Cm got commit
405 are as follows:
406 .Bl -tag -width Ds
407 .It Fl m Ar msg
408 Use the specified log message when creating the new commit.
409 Without the
410 .Fl m
411 option,
412 .Cm got commit
413 opens a temporary file in an editor where a log message can be written.
414 .El
415 .It Cm cherrypick Ar commit
416 Merge changes from a single
417 .Ar commit
418 into the work tree.
419 The specified
420 .Ar commit
421 must be on a different branch than the work tree's base commit.
422 The expected argument is a reference or a SHA1 hash which corresponds to
423 a commit object.
424 .Pp
425 Show the status of each affected file, using the following status codes:
426 .Bl -column YXZ description
427 .It G Ta file was merged
428 .It C Ta file was merged and conflicts occurred during merge
429 .It ! Ta changes destined for a missing file were not merged
430 .It D Ta file was deleted
431 .It d Ta file's deletion was obstructed by local modifications
432 .It A Ta new file was added
433 .It ~ Ta changes destined for a non-regular file were not merged
434 .El
435 .Pp
436 The merged changes will appear as local changes in the work tree, which
437 may be viewed with
438 .Cm got diff ,
439 amended manually or with further
440 .Cm got cherrypick
441 comands,
442 committed with
443 .Cm got commit ,
444 or discarded again with
445 .Cm got revert .
446 .Pp
447 .Cm got cherrypick
448 will refuse to run if certain preconditions are not met.
449 If the work tree contains multiple base commits it must first be updated
450 to a single base commit with
451 .Cm got update .
452 If the work tree already contains files with merge conflicts, these
453 conflicts must be resolved first.
454 .It Cm backout Ar commit
455 Reverse-merge changes from a single
456 .Ar commit
457 into the work tree.
458 The specified
459 .Ar commit
460 must be on the same branch as the work tree's base commit.
461 The expected argument is a reference or a SHA1 hash which corresponds to
462 a commit object.
463 .Pp
464 Show the status of each affected file, using the following status codes:
465 .Bl -column YXZ description
466 .It G Ta file was merged
467 .It C Ta file was merged and conflicts occurred during merge
468 .It ! Ta changes destined for a missing file were not merged
469 .It D Ta file was deleted
470 .It d Ta file's deletion was obstructed by local modifications
471 .It A Ta new file was added
472 .It ~ Ta changes destined for a non-regular file were not merged
473 .El
474 .Pp
475 The reverse-merged changes will appear as local changes in the work tree,
476 which may be viewed with
477 .Cm got diff ,
478 amended manually or with further
479 .Cm got cherrypick
480 comands,
481 committed with
482 .Cm got commit ,
483 or discarded again with
484 .Cm got revert .
485 .Pp
486 .Cm got backout
487 will refuse to run if certain preconditions are not met.
488 If the work tree contains multiple base commits it must first be updated
489 to a single base commit with
490 .Cm got update .
491 If the work tree already contains files with merge conflicts, these
492 conflicts must be resolved first.
493 .El
494 .Sh ENVIRONMENT
495 .Bl -tag -width GOT_AUTHOR
496 .It Ev GOT_AUTHOR
497 The author's name and email address for
498 .Cm got commit ,
499 for example:
500 .An Stefan Sperling Aq Mt stsp@openbsd.org
501 .It Ev VISUAL, Ev EDITOR
502 The editor spawned by
503 .Cm got commit .
504 .El
505 .Sh EXIT STATUS
506 .Ex -std got
507 .Sh EXAMPLES
508 .Pp
509 Clone an existing Git repository for use with
510 .Nm .
511 This step currently requires
512 .Xr git 1 :
513 .Pp
514 .Dl $ cd /var/git/
515 .Dl $ git clone --bare https://github.com/openbsd/src.git
516 .Pp
517 Check out a work tree from this Git repository to /usr/src:
518 .Pp
519 .Dl $ got checkout /var/git/src.git /usr/src
520 .Pp
521 View local changes in a work tree directory:
522 .Pp
523 .Dl $ got status
524 .Dl $ got diff | less
525 .Pp
526 In a work tree or a git repository directory, list all branch references:
527 .Pp
528 .Dl $ got branch -l
529 .Pp
530 In a work tree or a git repository directory, create a new branch called
531 .Dq unified-buffer-cache
532 which is forked off the
533 .Dq master
534 branch:
535 .Pp
536 .Dl $ got branch unified-buffer-cache master
537 .Pp
538 Switch an existing work tree to the branch
539 .Dq unified-buffer-cache .
540 Local changes in the work tree will be preserved and merged if necessary:
541 .Pp
542 .Dl $ got update -b unified-buffer-cache
543 .Pp
544 Create a new commit from local changes in a work tree directory.
545 This new commit will become the head commit of the work tree's current branch:
546 .Pp
547 .Dl $ got commit
548 .Pp
549 In a work tree or a git repository directory, view changes committed in
550 the 3 most recent commits to the work tree's branch, or the branch resolved
551 via the repository's HEAD reference, respectively:
552 .Pp
553 .Dl $ got log -p -l 3 -b
554 .Pp
555 Add new files and remove obsolete files in a work tree directory:
556 .Pp
557 .Dl $ got add sys/uvm/uvm_ubc.c
558 .Dl $ got rm sys/uvm/uvm_vnode.c
559 .Pp
560 Create a new commit from local changes in a work tree directory
561 with a pre-defined log message.
562 .Pp
563 .Dl $ got commit -m 'unify the buffer cache'
564 .Pp
565 Update any work tree checked out from the
566 .Dq unified-buffer-cache
567 branch to the latest commit on this branch:
568 .Pp
569 .Dl $ got update
570 .Pp
571 Fetch new upstream commits into the local repository's master branch.
572 This step currently requires
573 .Xr git 1 :
574 .Pp
575 .Dl $ cd /var/git/src.git
576 .Dl $ git fetch origin master:master
577 .Pp
578 Rebase the
579 .Dq unified-buffer-cache
580 branch on top of the new head commit of the
581 .Dq master
582 branch.
583 This step currently requires
584 .Xr git 1 :
585 .Pp
586 .Dl $ git clone /var/git/src.git ~/src-git-wt
587 .Dl $ cd ~/src-git-wt
588 .Dl $ git checkout unified-buffer-cache
589 .Dl $ git rebase master
590 .Dl $ git push -f
591 .Pp
592 Update the work tree to the newly rebased
593 .Dq unified-buffer-cache
594 branch:
595 .Pp
596 .Dl $ got update -b unified-buffer-cache
597 .Sh SEE ALSO
598 .Xr git-repository 5
599 .Xr got-worktree 5
600 .Sh AUTHORS
601 .An Stefan Sperling Aq Mt stsp@openbsd.org
602 .An Martin Pieuchot Aq Mt mpi@openbsd.org
603 .An joshua stein Aq Mt jcs@openbsd.org
604 .Sh CAVEATS
605 .Nm
606 is a work-in-progress and many commands remain to be implemented.
607 At present, the user has to fall back on
608 .Xr git 1
609 to perform many basic tasks.
610 .Pp
611 When working against a repository created with
612 .Dq git clone --bare ,
613 local commits to the
614 .Dq master
615 branch are discouraged, for now, if changes committed to the upstream
616 repository need to be tracked.
617 See the EXAMPLES section.