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