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 checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
64 Copy files from a repository into a new work tree.
65 If the
66 .Ar work tree path
67 is not specified, either use the last component of
68 .Ar repository path ,
69 or if a
70 .Ar path prefix
71 was specified use the last component of
72 .Ar path prefix .
73 .Pp
74 The options for
75 .Cm got checkout
76 are as follows:
77 .Bl -tag -width Ds
78 .It Fl b Ar branch
79 Check out files from the specified
80 .Ar branch .
81 If this option is not specified, a branch resolved via the repository's HEAD
82 reference will be used.
83 .It Fl c Ar commit
84 Check out files from the specified
85 .Ar commit .
86 If this option is not specified, the most recent commit on the selected
87 branch will be used.
88 .It Fl p Ar path-prefix
89 Restrict the work tree to a subset of the repository's tree hierarchy.
90 Only files beneath the specified
91 .Ar path-prefix
92 will be checked out.
93 .El
94 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
95 Update an existing work tree to a different commit.
96 Show the status of each affected file, using the following status codes:
97 .Bl -column YXZ description
98 .It U Ta file was updated and contained no local changes
99 .It G Ta file was updated and local changes were merged cleanly
100 .It C Ta file was updated and conflicts occurred during merge
101 .It D Ta file was deleted
102 .It A Ta new file was added
103 .It ~ Ta versioned file is obstructed by a non-regular file
104 .It ! Ta a missing versioned file was restored
105 .El
106 .Pp
107 If a
108 .Ar path
109 is specified, restrict the update operation to files at or within this path.
110 The path is required to exist in the update operation's target commit.
111 Files in the work tree outside this path will remain unchanged and will
112 retain their previously recorded base commit.
113 Some
114 .Nm
115 commands may refuse to run while the work tree contains files from
116 multiple base commits.
117 The base commit of such a work tree can be made consistent by running
118 .Cm got update
119 across the entire work tree.
120 Specifying a
121 .Ar path
122 is incompatible with the
123 .Fl b
124 option.
125 .Pp
126 The options for
127 .Cm got update
128 are as follows:
129 .Bl -tag -width Ds
130 .It Fl b Ar branch
131 Switch the work tree's branch reference to the specified
132 .Ar branch
133 before updating the work tree.
134 This option requires that all paths in the work tree are updated.
135 .It Fl c Ar commit
136 Update the work tree to the specified
137 .Ar commit .
138 The expected argument is a SHA1 hash which corresponds to a commit object.
139 If this option is not specified, the most recent commit on the work tree's
140 branch will be used.
141 .El
142 .It Cm status [ Ar path ]
143 Show the current modification status of files in a work tree,
144 using the following status codes:
145 .Bl -column YXZ description
146 .It M Ta modified file
147 .It A Ta file scheduled for addition in next commit
148 .It D Ta file scheduled for deletion in next commit
149 .It C Ta modified or added file which contains merge conflicts
150 .It ! Ta versioned file was expected on disk but is missing
151 .It ~ Ta versioned file is obstructed by a non-regular file
152 .It ? Ta unversioned item not tracked by
153 .Nm
154 .El
155 .Pp
156 If a
157 .Ar path
158 is specified, only show modifications within this path.
159 .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 ]
160 Display history of a repository.
161 If a
162 .Ar path
163 is specified, show only commits which modified this path.
164 .Pp
165 The options for
166 .Cm got log
167 are as follows:
168 .Bl -tag -width Ds
169 .It Fl b
170 Show the linear line of history of the current branch.
171 This option restricts history traversal to the first parent of each commit.
172 Commits which the branch was based on and merge commits which affected the
173 branch will be shown, but individual commits created on parallel branches
174 will be omitted.
175 .It Fl c Ar commit
176 Start traversing history at the specified
177 .Ar commit .
178 The expected argument is the name of a branch or a SHA1 hash which corresponds
179 to a commit object.
180 If this option is not specified, default to the work tree's current branch
181 if invoked in a work tree, or to the repository's HEAD reference.
182 .It Fl C Ar number
183 Set the number of context lines shown in diffs with
184 .Fl p .
185 By default, 3 lines of context are shown.
186 .It Fl l Ar N
187 Limit history traversal to a given number of commits.
188 .It Fl p
189 Display the patch of modifications made in each commit.
190 .It Fl r Ar repository-path
191 Use the repository at the specified path.
192 If not specified, assume the repository is located at or above the current
193 working directory.
194 If this directory is a
195 .Nm
196 work tree, use the repository path associated with this work tree.
197 .El
198 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
199 When invoked within a work tree with less than two arguments, display
200 uncommitted changes in the work tree.
201 If a
202 .Ar path
203 is specified, only show changes within this path.
204 .Pp
205 If two arguments are provided, treat each argument as a SHA1 hash which
206 corresponds to an object in the repository, and display differences
207 between these objects.
208 Both objects must be of the same type (blobs, trees, or commits).
209 .Pp
210 The options for
211 .Cm got diff
212 are as follows:
213 .Bl -tag -width Ds
214 .It Fl C Ar number
215 Set the number of context lines shown in the diff.
216 By default, 3 lines of context are shown.
217 .It Fl r Ar repository-path
218 Use the repository at the specified path.
219 If not specified, assume the repository is located at or above the current
220 working directory.
221 If this directory is a
222 .Nm
223 work tree, use the repository path associated with this work tree.
224 .El
225 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
226 Display line-by-line history of a file at the specified path.
227 .Pp
228 The options for
229 .Cm got blame
230 are as follows:
231 .Bl -tag -width Ds
232 .It Fl c Ar commit
233 Start traversing history at the specified
234 .Ar commit .
235 The expected argument is the name of a branch or a SHA1 hash which corresponds
236 to a commit object.
237 .It Fl r Ar repository-path
238 Use the repository at the specified path.
239 If not specified, assume the repository is located at or above the current
240 working directory.
241 If this directory is a
242 .Nm
243 work tree, use the repository path associated with this work tree.
244 .El
245 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
246 Display a listing of files and directories at the specified
247 directory path in the repository.
248 Entries shown in this listing may carry one of the following trailing
249 annotations:
250 .Bl -column YXZ description
251 .It / Ta entry is a directory
252 .It * Ta entry is an executable file
253 .El
254 .Pp
255 If no
256 .Ar path
257 is specified, list the repository path corresponding to the current
258 directory of the work tree, or the root directory of the repository
259 if there is no work tree.
260 .Pp
261 The options for
262 .Cm got tree
263 are as follows:
264 .Bl -tag -width Ds
265 .It Fl c Ar commit
266 List files and directories as they appear in the specified
267 .Ar commit .
268 The expected argument is the name of a branch or a SHA1 hash which corresponds
269 to a commit object.
270 .It Fl r Ar repository-path
271 Use the repository at the specified path.
272 If not specified, assume the repository is located at or above the current
273 working directory.
274 If this directory is a
275 .Nm
276 work tree, use the repository path associated with this work tree.
277 .It Fl i
278 Show object IDs of files (blob objects) and directories (tree objects).
279 .It Fl R
280 Recurse into sub-directories in the repository.
281 .El
282 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
283 Manage references in a repository.
284 .Pp
285 If no options are passed, expect two arguments and attempt to create,
286 or update, the reference with the given
287 .Ar name ,
288 and make it point at the given
289 .Ar target .
290 The target may be a SHA1 hash which corresponds to an existing object ID
291 in the repository, or an existing reference which will be resolved to an
292 object ID.
293 .Pp
294 The options for
295 .Cm got ref
296 are as follows:
297 .Bl -tag -width Ds
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 l
306 List all existing references in the repository.
307 .It Fl d Ar name
308 Delete the reference with the specified name from the repository.
309 .El
310 .It Cm add Ar file-path ...
311 Schedule unversioned files in a work tree for addition to the
312 repository in the next commit.
313 .It Cm rm Ar file-path
314 Remove a versioned file from a work tree and schedule it for deletion
315 from the repository in the next commit.
316 .Pp
317 The options for
318 .Cm got rm
319 are as follows:
320 .Bl -tag -width Ds
321 .It Fl f
322 Perform the operation even if the file contains uncommitted modifications.
323 .El
324 .It Cm revert Ar file-path
325 Revert any uncommited changes in the file at the specified path.
326 File contents will be overwritten with those contained in the
327 work tree's base commit. There is no way to bring discarded
328 changes back after
329 .Cm got revert !
330 .Pp
331 If the file was added with
332 .Cm got add
333 it will become an unversioned file again.
334 If the file was deleted with
335 .Cm got rm
336 it will be restored.
337 .It Cm commit [ Fl m Ar msg ] [ file-path ]
338 Create a new commit in the repository from local changes in a work tree
339 and use this commit as the new base commit for the work tree.
340 .Pp
341 Show the status of each affected file, using the following status codes:
342 .Bl -column YXZ description
343 .It M Ta modified file
344 .It D Ta file was deleted
345 .It A Ta new file was added
346 .El
347 .Pp
348 Files without local changes will retain their previously recorded base
349 commit.
350 Some
351 .Nm
352 commands may refuse to run while the work tree contains files from
353 multiple base commits.
354 The base commit of such a work tree can be made consistent by running
355 .Cm got update
356 across the entire work tree.
357 .Pp
358 The
359 .Cm got commit
360 command requires the
361 .Ev GOT_AUTHOR
362 environment variable to be set.
363 .Pp
364 The options for
365 .Cm got commit
366 are as follows:
367 .Bl -tag -width Ds
368 .It Fl m Ar msg
369 Use the specified log message when creating the new commit.
370 Without the
371 .Fl m
372 option,
373 .Cm got commit
374 opens a temporary file in an editor where a log message can be written.
375 .El
376 .El
377 .Sh ENVIRONMENT
378 .Bl -tag -width GOT_AUTHOR
379 .It Ev GOT_AUTHOR
380 The author's name and email address for
381 .Cm got commit ,
382 for example:
383 .An Stefan Sperling Aq Mt stsp@openbsd.org
384 .It Ev VISUAL, Ev EDITOR
385 The editor spawned by
386 .Cm got commit .
387 .El
388 .Sh EXIT STATUS
389 .Ex -std got
390 .Sh EXAMPLES
391 .Pp
392 Clone an existing Git repository for use with
393 .Nm .
394 This step currently requires
395 .Xr git 1 :
396 .Pp
397 .Dl $ cd /var/git/
398 .Dl $ git clone --bare https://github.com/openbsd/src.git
399 .Pp
400 Check out a work tree from this Git repository to /usr/src:
401 .Pp
402 .Dl $ got checkout /var/git/src.git /usr/src
403 .Pp
404 View local changes in a work tree directory:
405 .Pp
406 .Dl $ got status
407 .Dl $ got diff | less
408 .Pp
409 In a work tree or a git repository directory, list all branch references:
410 .Pp
411 .Dl $ got ref -l | grep ^refs/heads
412 .Pp
413 In a work tree or a git repository directory, create a new branch called
414 .Dq unified-buffer-cache
415 which is forked off the
416 .Dq master
417 branch:
418 .Pp
419 .Dl $ got ref refs/heads/unified-buffer-cache refs/heads/master
420 .Pp
421 Switch an existing work tree to the branch
422 .Dq unified-buffer-cache .
423 Local changes in the work tree will be preserved and merged if necessary:
424 .Pp
425 .Dl $ got update -b unified-buffer-cache
426 .Pp
427 Create a new commit from local changes in a work tree directory.
428 This new commit will become the head commit of the work tree's current branch:
429 .Pp
430 .Dl $ got commit
431 .Pp
432 In a work tree or a git repository directory, view changes committed in
433 the 3 most recent commits to the work tree's branch, or the branch resolved
434 via the repository's HEAD reference, respectively:
435 .Pp
436 .Dl $ got log -p -l 3 -b
437 .Pp
438 Add new files and remove obsolete files in a work tree directory:
439 .Pp
440 .Dl $ got add sys/uvm/uvm_ubc.c
441 .Dl $ got rm sys/uvm/uvm_vnode.c
442 .Pp
443 Create a new commit from local changes in a work tree directory
444 with a pre-defined log message.
445 .Pp
446 .Dl $ got commit -m 'unify the buffer cache'
447 .Pp
448 Update any work tree checked out from the
449 .Dq unified-buffer-cache
450 branch to the latest commit on this branch:
451 .Pp
452 .Dl $ got update
453 .Pp
454 Fetch new upstream commits into the local repository's master branch:
455 .Pp
456 .Dl $ cd /var/git/src.git
457 .Dl $ git fetch origin master:master
458 .Pp
459 Rebase the
460 .Dq unified-buffer-cache
461 branch on top of the new head commit of the
462 .Dq master
463 branch.
464 This step currently requires
465 .Xr git 1 :
466 .Pp
467 .Dl $ git clone /var/git/src.git ~/src-git-wt
468 .Dl $ cd ~/src-git-wt
469 .Dl $ git checkout unified-buffer-cache
470 .Dl $ git rebase master
471 .Dl $ git push -f
472 .Pp
473 Update the work tree to the newly rebased
474 .Dq unified-buffer-cache
475 branch:
476 .Pp
477 .Dl $ got update -b unified-buffer-cache
478 .Sh SEE ALSO
479 .Xr git-repository 5
480 .Xr got-worktree 5
481 .Sh AUTHORS
482 .An Stefan Sperling Aq Mt stsp@openbsd.org
483 .An Martin Pieuchot Aq Mt mpi@openbsd.org
484 .An joshua stein Aq Mt jcs@openbsd.org
485 .Sh CAVEATS
486 .Nm
487 is a work-in-progress and many commands remain to be implemented.
488 At present, the user has to fall back on
489 .Xr git 1
490 to perform many basic tasks.
491 .Pp
492 When working against a repository created with
493 .Dq git clone --bare ,
494 local commits to the
495 .Dq master
496 branch are discouraged, for now, if changes committed to the upstream
497 repository need to be tracked.
498 See the EXAMPLES section.