.\" .\" Copyright (c) 2017 Martin Pieuchot .\" Copyright (c) 2018, 2019 Stefan Sperling .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ .Dt GOT 1 .Os .Sh NAME .Nm got .Nd game of trees .Sh SYNOPSIS .Nm .Ar command .Op Fl h .Op Ar arg ... .Sh DESCRIPTION .Nm is a version control system which stores the history of tracked files in a Git repository, as used by the Git version control system. This repository format is described in .Xr git-repository 5 . .Pp .Nm is a .Dq distributed version control system because every copy of a repository is writeable. Modifications made to files can be synchronized between repositories at any time. .Pp Files managed by .Nm must be checked out from the repository for modification. Checked out files are stored in a .Em work tree which can be placed at an arbitrary directory in the filesystem hierarchy. The on-disk format of this work tree is described in .Xr got-worktree 5 . .Pp .Nm provides global and command-specific options. Global options must preceed the command name, and are as follows: .Bl -tag -width tenletters .It Fl h Display usage information. .El .Pp The commands for .Nm are as follows: .Bl -tag -width checkout .It Cm init Ar path Create a new empty repository at the specified .Ar path . .It Cm checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ] Copy files from a repository into a new work tree. If the .Ar work tree path is not specified, either use the last component of .Ar repository path , or if a .Ar path prefix was specified use the last component of .Ar path prefix . .Pp The options for .Cm got checkout are as follows: .Bl -tag -width Ds .It Fl b Ar branch Check out files from the specified .Ar branch . If this option is not specified, a branch resolved via the repository's HEAD reference will be used. .It Fl c Ar commit Check out files from the specified .Ar commit . The expected argument is a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. If this option is not specified, the most recent commit on the selected branch will be used. .It Fl p Ar path-prefix Restrict the work tree to a subset of the repository's tree hierarchy. Only files beneath the specified .Ar path-prefix will be checked out. .El .It Cm co Short alias for .Cm checkout . .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ] Update an existing work tree to a different commit. Show the status of each affected file, using the following status codes: .Bl -column YXZ description .It U Ta file was updated and contained no local changes .It G Ta file was updated and local changes were merged cleanly .It C Ta file was updated and conflicts occurred during merge .It D Ta file was deleted .It A Ta new file was added .It ~ Ta versioned file is obstructed by a non-regular file .It ! Ta a missing versioned file was restored .El .Pp If a .Ar path is specified, restrict the update operation to files at or within this path. The path is required to exist in the update operation's target commit. Files in the work tree outside this path will remain unchanged and will retain their previously recorded base commit. Some .Nm commands may refuse to run while the work tree contains files from multiple base commits. The base commit of such a work tree can be made consistent by running .Cm got update across the entire work tree. Specifying a .Ar path is incompatible with the .Fl b option. .Pp The options for .Cm got update are as follows: .Bl -tag -width Ds .It Fl b Ar branch Switch the work tree's branch reference to the specified .Ar branch before updating the work tree. This option requires that all paths in the work tree are updated. .It Fl c Ar commit Update the work tree to the specified .Ar commit . The expected argument is a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. If this option is not specified, the most recent commit on the work tree's branch will be used. .El .It Cm up Short alias for .Cm update . .It Cm status [ Ar path ] Show the current modification status of files in a work tree, using the following status codes: .Bl -column YXZ description .It M Ta modified file .It A Ta file scheduled for addition in next commit .It D Ta file scheduled for deletion in next commit .It C Ta modified or added file which contains merge conflicts .It ! Ta versioned file was expected on disk but is missing .It ~ Ta versioned file is obstructed by a non-regular file .It ? Ta unversioned item not tracked by .Nm .El .Pp If a .Ar path is specified, only show modifications within this path. .It Cm st Short alias for .Cm status . .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 ] Display history of a repository. If a .Ar path is specified, show only commits which modified this path. .Pp The options for .Cm got log are as follows: .Bl -tag -width Ds .It Fl b Show the linear line of history of the current branch. This option restricts history traversal to the first parent of each commit. Commits which the branch was based on and merge commits which affected the branch will be shown, but individual commits created on parallel branches will be omitted. .It Fl c Ar commit Start traversing history at the specified .Ar commit . The expected argument is the name of a branch or a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. If this option is not specified, default to the work tree's current branch if invoked in a work tree, or to the repository's HEAD reference. .It Fl C Ar number Set the number of context lines shown in diffs with .Fl p . By default, 3 lines of context are shown. .It Fl l Ar N Limit history traversal to a given number of commits. .It Fl p Display the patch of modifications made in each commit. .It Fl r Ar repository-path Use the repository at the specified path. If not specified, assume the repository is located at or above the current working directory. If this directory is a .Nm work tree, use the repository path associated with this work tree. .El .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ] When invoked within a work tree with less than two arguments, display uncommitted changes in the work tree. If a .Ar path is specified, only show changes within this path. .Pp If two arguments are provided, treat each argument as a reference, or an object ID SHA1 hash, and display differences between these objects. Both objects must be of the same type (blobs, trees, or commits). An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. .Pp The options for .Cm got diff are as follows: .Bl -tag -width Ds .It Fl C Ar number Set the number of context lines shown in the diff. By default, 3 lines of context are shown. .It Fl r Ar repository-path Use the repository at the specified path. If not specified, assume the repository is located at or above the current working directory. If this directory is a .Nm work tree, use the repository path associated with this work tree. .El .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path Display line-by-line history of a file at the specified path. .Pp The options for .Cm got blame are as follows: .Bl -tag -width Ds .It Fl c Ar commit Start traversing history at the specified .Ar commit . The expected argument is the name of a branch or a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. .It Fl r Ar repository-path Use the repository at the specified path. If not specified, assume the repository is located at or above the current working directory. If this directory is a .Nm work tree, use the repository path associated with this work tree. .El .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ] Display a listing of files and directories at the specified directory path in the repository. Entries shown in this listing may carry one of the following trailing annotations: .Bl -column YXZ description .It / Ta entry is a directory .It * Ta entry is an executable file .El .Pp If no .Ar path is specified, list the repository path corresponding to the current directory of the work tree, or the root directory of the repository if there is no work tree. .Pp The options for .Cm got tree are as follows: .Bl -tag -width Ds .It Fl c Ar commit List files and directories as they appear in the specified .Ar commit . The expected argument is the name of a branch or a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. .It Fl r Ar repository-path Use the repository at the specified path. If not specified, assume the repository is located at or above the current working directory. If this directory is a .Nm work tree, use the repository path associated with this work tree. .It Fl i Show object IDs of files (blob objects) and directories (tree objects). .It Fl R Recurse into sub-directories in the repository. .El .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ] Manage references in a repository. .Pp If no options are passed, expect two arguments and attempt to create, or update, the reference with the given .Ar name , and make it point at the given .Ar target . The target may be an object ID SHA1 hash or an existing reference which will be resolved to an object ID. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. .Pp The options for .Cm got ref are as follows: .Bl -tag -width Ds .It Fl r Ar repository-path Use the repository at the specified path. If not specified, assume the repository is located at or above the current working directory. If this directory is a .Nm work tree, use the repository path associated with this work tree. .It Fl l List all existing references in the repository. .It Fl d Ar name Delete the reference with the specified name from the repository. .El .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ] Manage branches in a repository. .Pp Branches are managed via references which live in the .Dq refs/heads/ reference namespace. The .Cm got branch command operates on references in this namespace only. .Pp If no options are passed, expect one or two arguments and attempt to create a branch with the given .Ar name , and make it point at the given .Ar base-branch . If no .Ar base-branch is specified, default to the work tree's current branch if invoked in a work tree, or to the repository's HEAD reference. .Pp The options for .Cm got branch are as follows: .Bl -tag -width Ds .It Fl r Ar repository-path Use the repository at the specified path. If not specified, assume the repository is located at or above the current working directory. If this directory is a .Nm work tree, use the repository path associated with this work tree. .It Fl l List all existing branches in the repository. .Pp If invoked in a work tree, the work tree's current branch is shown with one the following annotations: .Bl -column YXZ description .It * Ta work tree's base commit matches the branch tip .It ~ Ta work tree's base commit is out-of-date .El .It Fl d Ar name Delete the branch with the specified name from the repository. Only the branch reference is deleted. Any commit, tree, and blob objects belonging to the branch remain in the repository and may be removed separately with .Xr git-gc 1 . .El .It Cm br Short alias for .Cm branch . .It Cm add Ar file-path ... Schedule unversioned files in a work tree for addition to the repository in the next commit. .It Cm remove Ar file-path ... Remove versioned files from a work tree and schedule them for deletion from the repository in the next commit. .Pp The options for .Cm got remove are as follows: .Bl -tag -width Ds .It Fl f Perform the operation even if a file contains uncommitted modifications. .El .It Cm rm Short alias for .Cm remove . .It Cm revert Ar file-path ... Revert any uncommited changes in files at the specified paths. File contents will be overwritten with those contained in the work tree's base commit. There is no way to bring discarded changes back after .Cm got revert ! .Pp If a file was added with .Cm got add it will become an unversioned file again. If a file was deleted with .Cm got remove it will be restored. .It Cm rv Short alias for .Cm revert . .It Cm commit [ Fl m Ar message ] [ file-path ] Create a new commit in the repository from local changes in a work tree and use this commit as the new base commit for the work tree. .Pp Show the status of each affected file, using the following status codes: .Bl -column YXZ description .It M Ta modified file .It D Ta file was deleted .It A Ta new file was added .El .Pp Files without local changes will retain their previously recorded base commit. Some .Nm commands may refuse to run while the work tree contains files from multiple base commits. The base commit of such a work tree can be made consistent by running .Cm got update across the entire work tree. .Pp The .Cm got commit command requires the .Ev GOT_AUTHOR environment variable to be set. .Pp The options for .Cm got commit are as follows: .Bl -tag -width Ds .It Fl m Ar message Use the specified log message when creating the new commit. Without the .Fl m option, .Cm got commit opens a temporary file in an editor where a log message can be written. .El .It Cm ci Short alias for .Cm commit . .It Cm cherrypick Ar commit Merge changes from a single .Ar commit into the work tree. The specified .Ar commit must be on a different branch than the work tree's base commit. The expected argument is a reference or a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. .Pp Show the status of each affected file, using the following status codes: .Bl -column YXZ description .It G Ta file was merged .It C Ta file was merged and conflicts occurred during merge .It ! Ta changes destined for a missing file were not merged .It D Ta file was deleted .It d Ta file's deletion was obstructed by local modifications .It A Ta new file was added .It ~ Ta changes destined for a non-regular file were not merged .El .Pp The merged changes will appear as local changes in the work tree, which may be viewed with .Cm got diff , amended manually or with further .Cm got cherrypick comands, committed with .Cm got commit , or discarded again with .Cm got revert . .Pp .Cm got cherrypick will refuse to run if certain preconditions are not met. If the work tree contains multiple base commits it must first be updated to a single base commit with .Cm got update . If the work tree already contains files with merge conflicts, these conflicts must be resolved first. .It Cm cy Short alias for .Cm cherrypick . .It Cm backout Ar commit Reverse-merge changes from a single .Ar commit into the work tree. The specified .Ar commit must be on the same branch as the work tree's base commit. The expected argument is a reference or a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. .Pp Show the status of each affected file, using the following status codes: .Bl -column YXZ description .It G Ta file was merged .It C Ta file was merged and conflicts occurred during merge .It ! Ta changes destined for a missing file were not merged .It D Ta file was deleted .It d Ta file's deletion was obstructed by local modifications .It A Ta new file was added .It ~ Ta changes destined for a non-regular file were not merged .El .Pp The reverse-merged changes will appear as local changes in the work tree, which may be viewed with .Cm got diff , amended manually or with further .Cm got backout comands, committed with .Cm got commit , or discarded again with .Cm got revert . .Pp .Cm got backout will refuse to run if certain preconditions are not met. If the work tree contains multiple base commits it must first be updated to a single base commit with .Cm got update . If the work tree already contains files with merge conflicts, these conflicts must be resolved first. .It Cm bo Short alias for .Cm backout . .It Cm rebase Ar branch Rebase commits on the specified .Ar branch onto the tip of the current branch of the work tree. The .Ar branch must share common ancestry with the work tree's current branch. Rebasing begins with the first descendent commit of the youngest common ancestor commit shared by the specified .Ar branch and the work tree's current branch, and stops once the tip commit of the specified .Ar branch has been rebased. .Pp Rebased commits are accumulated on a temporary branch and represent the same changes with the same log messages as their counterparts on the original .Ar branch , but with different commit IDs. Once rebasing has completed successfully, the temporary branch becomes the new version of the specified .Ar branch and the work tree is automatically switched to it. .Pp While rebasing commits, show the status of each affected file, using the following status codes: .Bl -column YXZ description .It G Ta file was merged .It C Ta file was merged and conflicts occurred during merge .It ! Ta changes destined for a missing file were not merged .It D Ta file was deleted .It d Ta file's deletion was obstructed by local modifications .It A Ta new file was added .It ~ Ta changes destined for a non-regular file were not merged .El .Pp If merge conflicts occur the rebase operation is interrupted and may be continued once conflicts have been resolved. Alternatively, the rebase operation may be aborted which will leave .Ar branch unmodified and the work tree switched back to its original branch. .Pp If a merge conflict is resolved in a way which renders the merged change into a no-op change, the corresponding commit will be elided when the rebase operation continues. .Pp .Cm got rebase will refuse to run if certain preconditions are not met. If the work tree contains multiple base commits it must first be updated to a single base commit with .Cm got update . If the work tree contains local changes, these changes must first be committed with .Cm got commit or reverted with .Cm got revert . If the .Ar branch contains changes to files outside of the work tree's path prefix, the work tree cannot be used to rebase this branch. .Pp The .Cm got update and .Cm got commit commands will refuse to run while a rebase operation is in progress. Other commands which manipulate the work tree may be used for conflict resolution purposes. .Pp The options for .Cm got rebase are as follows: .Bl -tag -width Ds .It Fl a Abort an interrupted rebase operation. .It Fl c Continue an interrupted rebase operation. .El .It Cm rb Short alias for .Cm rebase . .El .Sh ENVIRONMENT .Bl -tag -width GOT_AUTHOR .It Ev GOT_AUTHOR The author's name and email address for .Cm got commit , for example: .An Stefan Sperling Aq Mt stsp@openbsd.org .It Ev VISUAL, Ev EDITOR The editor spawned by .Cm got commit . .El .Sh EXIT STATUS .Ex -std got .Sh EXAMPLES .Pp Clone an existing Git repository for use with .Nm . This step currently requires .Xr git 1 : .Pp .Dl $ cd /var/git/ .Dl $ git clone --bare https://github.com/openbsd/src.git .Pp Check out a work tree from this Git repository to /usr/src: .Pp .Dl $ got checkout /var/git/src.git /usr/src .Pp View local changes in a work tree directory: .Pp .Dl $ got status .Dl $ got diff | less .Pp In a work tree or a git repository directory, list all branch references: .Pp .Dl $ got branch -l .Pp In a work tree or a git repository directory, create a new branch called .Dq unified-buffer-cache which is forked off the .Dq master branch: .Pp .Dl $ got branch unified-buffer-cache master .Pp Switch an existing work tree to the branch .Dq unified-buffer-cache . Local changes in the work tree will be preserved and merged if necessary: .Pp .Dl $ got update -b unified-buffer-cache .Pp Create a new commit from local changes in a work tree directory. This new commit will become the head commit of the work tree's current branch: .Pp .Dl $ got commit .Pp In a work tree or a git repository directory, view changes committed in the 3 most recent commits to the work tree's branch, or the branch resolved via the repository's HEAD reference, respectively: .Pp .Dl $ got log -p -l 3 -b .Pp Add new files and remove obsolete files in a work tree directory: .Pp .Dl $ got add sys/uvm/uvm_ubc.c .Dl $ got remove sys/uvm/uvm_vnode.c .Pp Create a new commit from local changes in a work tree directory with a pre-defined log message. .Pp .Dl $ got commit -m 'unify the buffer cache' .Pp Update any work tree checked out from the .Dq unified-buffer-cache branch to the latest commit on this branch: .Pp .Dl $ got update .Pp Fetch new upstream commits into the local repository's master branch. This step currently requires .Xr git 1 : .Pp .Dl $ cd /var/git/src.git .Dl $ git fetch origin master:master .Pp Rebase the .Dq unified-buffer-cache branch on top of the new head commit of the .Dq master branch. .Pp .Dl $ got update -b master .Dl $ got rebase unified-buffer-cache .Sh SEE ALSO .Xr git-repository 5 .Xr got-worktree 5 .Sh AUTHORS .An Stefan Sperling Aq Mt stsp@openbsd.org .An Martin Pieuchot Aq Mt mpi@openbsd.org .An joshua stein Aq Mt jcs@openbsd.org .Sh CAVEATS .Nm is a work-in-progress and many commands remain to be implemented. At present, the user has to fall back on .Xr git 1 to perform many basic tasks. .Pp When working against a repository created with .Dq git clone --bare , local commits to the .Dq master branch are discouraged, for now, if changes committed to the upstream repository need to be tracked. See the EXAMPLES section.