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