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 c Ar commit ] [ Fl C Ar number ] [ Fl f ] [ 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 c Ar commit
170 Start traversing history at the specified
171 .Ar commit .
172 The expected argument is the name of a branch or a SHA1 hash which corresponds
173 to a commit object.
174 If this option is not specified, default to the work tree's current branch
175 if invoked in a work tree, or to the repository's HEAD reference.
176 .It Fl C Ar number
177 Set the number of context lines shown in diffs with
178 .Fl p .
179 By default, 3 lines of context are shown.
180 .It Fl f
181 Restrict history traversal to the first parent of each commit.
182 This shows the linear history of the current branch only.
183 Merge commits which affected the current branch will be shown but
184 individual commits which originated on other branches will be omitted.
185 .It Fl l Ar N
186 Limit history traversal to a given number of commits.
187 .It Fl p
188 Display the patch of modifications made in each commit.
189 .It Fl r Ar repository-path
190 Use the repository at the specified path.
191 If not specified, assume the repository is located at or above the current
192 working directory.
193 If this directory is a
194 .Nm
195 work tree, use the repository path associated with this work tree.
196 .El
197 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
198 When invoked within a work tree with less than two arguments, display
199 uncommitted changes in the work tree.
200 If a
201 .Ar path
202 is specified, only show changes within this path.
203 .Pp
204 If two arguments are provided, treat each argument as a SHA1 hash which
205 corresponds to an object in the repository, and display differences
206 between these objects.
207 Both objects must be of the same type (blobs, trees, or commits).
208 .Pp
209 The options for
210 .Cm got diff
211 are as follows:
212 .Bl -tag -width Ds
213 .It Fl C Ar number
214 Set the number of context lines shown in the diff.
215 By default, 3 lines of context are shown.
216 .It Fl r Ar repository-path
217 Use the repository at the specified path.
218 If not specified, assume the repository is located at or above the current
219 working directory.
220 If this directory is a
221 .Nm
222 work tree, use the repository path associated with this work tree.
223 .El
224 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
225 Display line-by-line history of a file at the specified path.
226 .Pp
227 The options for
228 .Cm got blame
229 are as follows:
230 .Bl -tag -width Ds
231 .It Fl c Ar commit
232 Start traversing history at the specified
233 .Ar commit .
234 The expected argument is the name of a branch or a SHA1 hash which corresponds
235 to a commit object.
236 .It Fl r Ar repository-path
237 Use the repository at the specified path.
238 If not specified, assume the repository is located at or above the current
239 working directory.
240 If this directory is a
241 .Nm
242 work tree, use the repository path associated with this work tree.
243 .El
244 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
245 Display a listing of files and directories at the specified
246 directory path in the repository.
247 Entries shown in this listing may carry one of the following trailing
248 annotations:
249 .Bl -column YXZ description
250 .It / Ta entry is a directory
251 .It * Ta entry is an executable file
252 .El
253 .Pp
254 If no
255 .Ar path
256 is specified, list the repository path corresponding to the current
257 directory of the work tree, or the root directory of the repository
258 if there is no work tree.
259 .Pp
260 The options for
261 .Cm got tree
262 are as follows:
263 .Bl -tag -width Ds
264 .It Fl c Ar commit
265 List files and directories as they appear in the specified
266 .Ar commit .
267 The expected argument is the name of a branch or a SHA1 hash which corresponds
268 to a commit object.
269 .It Fl r Ar repository-path
270 Use the repository at the specified path.
271 If not specified, assume the repository is located at or above the current
272 working directory.
273 If this directory is a
274 .Nm
275 work tree, use the repository path associated with this work tree.
276 .It Fl i
277 Show object IDs of files (blob objects) and directories (tree objects).
278 .It Fl R
279 Recurse into sub-directories in the repository.
280 .El
281 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
282 Manage references in a repository.
283 .Pp
284 If no options are passed, expect two arguments and attempt to create,
285 or update, the reference with the given
286 .Ar name ,
287 and make it point at the given
288 .Ar target .
289 The target may be a SHA1 hash which corresponds to an existing object ID
290 in the repository, or an existing reference which will be resolved to an
291 object ID.
292 .Pp
293 The options for
294 .Cm got ref
295 are as follows:
296 .Bl -tag -width Ds
297 .It Fl r Ar repository-path
298 Use the repository at the specified path.
299 If not specified, assume the repository is located at or above the current
300 working directory.
301 If this directory is a
302 .Nm
303 work tree, use the repository path associated with this work tree.
304 .It Fl l
305 List all existing references in the repository.
306 .It Fl d Ar name
307 Delete the reference with the specified name from the repository.
308 .El
309 .It Cm add Ar file-path ...
310 Schedule unversioned files in a work tree for addition to the
311 repository in the next commit.
312 .It Cm rm Ar file-path
313 Remove a versioned file from a work tree and schedule it for deletion
314 from the repository in the next commit.
315 .Pp
316 The options for
317 .Cm got rm
318 are as follows:
319 .Bl -tag -width Ds
320 .It Fl f
321 Perform the operation even if the file contains uncommitted modifications.
322 .El
323 .It Cm revert Ar file-path
324 Revert any uncommited changes in the file at the specified path.
325 File contents will be overwritten with those contained in the
326 work tree's base commit. There is no way to bring discarded
327 changes back after
328 .Cm got revert !
329 .Pp
330 If the file was added with
331 .Cm got add
332 it will become an unversioned file again.
333 If the file was deleted with
334 .Cm got rm
335 it will be restored.
336 .It Cm commit [ Fl m Ar msg ] [ file-path ]
337 Create a new commit in the repository from local changes in a work tree
338 and use this commit as the new base commit for the work tree.
339 .Pp
340 Show the status of each affected file, using the following status codes:
341 .Bl -column YXZ description
342 .It M Ta modified file
343 .It D Ta file was deleted
344 .It A Ta new file was added
345 .El
346 .Pp
347 Files without local changes will retain their previously recorded base
348 commit.
349 Some
350 .Nm
351 commands may refuse to run while the work tree contains files from
352 multiple base commits.
353 The base commit of such a work tree can be made consistent by running
354 .Cm got update
355 across the entire work tree.
356 .Pp
357 The
358 .Cm got commit
359 command requires the
360 .Ev GOT_AUTHOR
361 environment variable to be set.
362 .Pp
363 The options for
364 .Cm got commit
365 are as follows:
366 .Bl -tag -width Ds
367 .It Fl m Ar msg
368 Use the specified log message when creating the new commit.
369 Without the
370 .Fl m
371 option,
372 .Cm got commit
373 opens a temporary file in an editor where a log message can be written.
374 .El
375 .El
376 .Sh ENVIRONMENT
377 .Bl -tag -width GOT_AUTHOR
378 .It Ev GOT_AUTHOR
379 The author's name and email address for
380 .Cm got commit ,
381 for example:
382 .An Stefan Sperling Aq Mt stsp@openbsd.org
383 .It Ev VISUAL, Ev EDITOR
384 The editor spawned by
385 .Cm got commit .
386 .El
387 .Sh EXIT STATUS
388 .Ex -std got
389 .Sh EXAMPLES
390 Check out a work tree of
391 .Ox
392 kernel sources from a Git repository at /var/repo/openbsd-src to ~/sys:
393 .Pp
394 .Dl $ got checkout -p sys /var/repo/openbsd-src ~/sys
395 .Pp
396 Create a new branch
397 .Dq mybranch
398 which is forked off the
399 .Dq master
400 branch:
401 .Pp
402 .Dl $ got ref refs/heads/mybranch refs/heads/master
403 .Sh SEE ALSO
404 .Xr git-repository 5
405 .Xr got-worktree 5
406 .Sh AUTHORS
407 .An Stefan Sperling Aq Mt stsp@openbsd.org
408 .An Martin Pieuchot Aq Mt mpi@openbsd.org
409 .An joshua stein Aq Mt jcs@openbsd.org