.\" .\" 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 precede the command name, and are as follows: .Bl -tag -width tenletters .It Fl h Display usage information and exit immediately. .It Fl V Display program version and exit immediately. .El .Pp The commands for .Nm are as follows: .Bl -tag -width checkout .It Cm init Ar repository-path Create a new empty repository at the specified .Ar repository-path . .Pp After .Cm got init , the .Cm got import command must be used to populate the empty repository before .Cm got checkout can be used. .It Cm in Short alias for .Cm init . .It Cm import Oo Fl b Ar branch Oc Oo Fl m Ar message Oc Oo Fl r Ar repository-path Oc Oo Fl I Ar pattern Oc Ar directory Create an initial commit in a repository from the file hierarchy within the specified .Ar directory . The created commit will not have any parent commits, i.e. it will be a root commit. Also create a new reference which provides a branch name for the newly created commit. Show the path of each imported file to indicate progress. .Pp The .Cm got import command requires the .Ev GOT_AUTHOR environment variable to be set. .Pp The options for .Cm got import are as follows: .Bl -tag -width Ds .It Fl b Ar branch Create the specified .Ar branch instead of creating the default branch .Dq master . Use of this option is required if the .Dq master branch already exists. .It Fl m Ar message Use the specified log message when creating the new commit. Without the .Fl m option, .Cm got import opens a temporary file in an editor where a log message can be written. .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. .It Fl I Ar pattern Ignore files or directories with a name which matches the specified .Ar pattern . This option may be specified multiple times to build a list of ignore patterns. The .Ar pattern follows the globbing rules documented in .Xr glob 7 . .El .It Cm im Short alias for .Cm import . .It Cm checkout Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Oo Fl p Ar path-prefix Oc Ar repository-path Op Ar 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 a commit on 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 on the selected branch. The expected argument is a commit ID SHA1 hash or an existing reference or tag name which will be resolved to a commit ID. 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 Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Op 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 \(a~ Ta versioned file is obstructed by a non-regular file .It ! Ta a missing versioned file was restored .El .Pp If no .Ar path is specified, update the entire work tree. Otherwise, restrict the update operation to files at or within the specified paths. Each path is required to exist in the update operation's target commit. Files in the work tree outside specified paths 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 .Cm got update cannot update paths with staged changes. If changes have been staged with .Cm got stage , these changes must first be committed with .Cm got commit or unstaged with .Cm got unstage . .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 or an existing reference or tag name which will be resolved to a commit ID. 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 Op 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 \(a~ Ta versioned file is obstructed by a non-regular file .It ? Ta unversioned item not tracked by .Nm .El .Pp If no .Ar path is specified, show modifications in the entire work tree. Otherwise, show modifications at or within the specified paths. .Pp If changes have been staged with .Cm got stage , staged changes are shown in the second output column, using the following status codes: .Bl -column YXZ description .It M Ta file modification is staged .It A Ta file addition is staged .It D Ta file deletion is staged .El .Pp Changes created on top of staged changes are indicated in the first column: .Bl -column YXZ description .It MM Ta file was modified after earlier changes have been staged .It MA Ta file was modified after having been staged for addition .El .Pp For compatibility with .Xr cvs 1 , .Cm got status parses .Pa .cvsignore files in each traversed directory and will not display unversioned files which match .Xr glob 7 ignore patterns contained in .Pa .cvsignore files. Unlike .Xr cvs 1 , .Cm got status only supports a single ignore pattern per line. .It Cm st Short alias for .Cm status . .It Cm log Oo Fl c Ar commit Oc Oo Fl C Ar number Oc Oo Fl f Oc Oo Fl l Ar N Oc Oo Fl p Oc Oo Fl r Ar repository-path Oc Op Ar 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 c Ar commit Start traversing history at the specified .Ar commit . The expected argument is a commit ID SHA1 hash or an existing reference or tag name which will be resolved to a commit ID. 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 f Restrict history traversal to the first parent of each commit. This shows the linear history of the current branch only. Merge commits which affected the current branch will be shown but individual commits which originated on other branches will be omitted. .It Fl l Ar N Limit history traversal to a given number of commits. If this option is not specified, a default limit value of zero is used, which is treated as an unbounded limit. The .Ev GOT_LOG_DEFAULT_LIMIT environment variable may be set to change this default value. .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 Oo Fl C Ar number Oc Oo Fl r Ar repository-path Oc Oo Fl s Oc Op 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, a tag name, or an object ID SHA1 hash, and display differences between the corresponding 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. .It Fl s Show changes staged with .Cm got stage instead of showing local changes. This option is only valid when .Cm got diff is invoked in a work tree. .El .It Cm di Short alias for .Cm diff . .It Cm blame Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc 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 a commit ID SHA1 hash or an existing reference or tag name which will be resolved to a commit ID. 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 bl Short alias for .Cm blame . .It Cm tree Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Oo Fl i Oc Oo Fl R Oc Op 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 symbolic link .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 a commit ID SHA1 hash or an existing reference or tag name which will be resolved to a commit ID. 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 tr Short alias for .Cm tree . .It Cm ref Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl d Ar name Oc Oo Fl s Oc Op 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. .It Fl s Create a symbolic reference pointing at the specified .Ar target , which must be an existing reference. Care should be taken not to create loops between references when this option is used. .El .It Cm branch Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl d Ar name Oc Op Ar name Op 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. 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 \(a~ 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 Git's garbage collector. .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 Oo Fl p Oc Oo Fl F Ar response-script Oc Oo Fl R Oc Ar path ... Revert any uncommitted 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. .Pp The options for .Cm got revert are as follows: .Bl -tag -width Ds .It Fl p Instead of reverting all changes in files, interactively select or reject changes to revert based on .Dq y (revert change), .Dq n (keep change), and .Dq q (quit reverting this file) responses. If a file is in modified status, individual patches derived from the modified file content can be reverted. Files in added or deleted status may only be reverted in their entirety. .It Fl F Ar response-script With the .Fl p option, read .Dq y , .Dq n , and .Dq q responses line-by-line from the specified .Ar response-script file instead of prompting interactively. .It Fl R Permit recursion into directories. If this option is not specified, .Cm got revert will refuse to run if a specified .Ar path is a directory. .El .It Cm rv Short alias for .Cm revert . .It Cm commit Oo Fl m Ar message Oc Op Ar path ... Create a new commit in the repository from changes in a work tree and use this commit as the new base commit for the work tree. If no .Ar path is specified, commit all changes in the work tree. Otherwise, commit changes at or within the specified paths. .Pp If changes have been explicitly staged for commit with .Cm got stage , only commit staged changes and reject any specified paths which have not been staged. .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 which are not part of the new commit 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 .Pp .Cm got commit will refuse to run if certain preconditions are not met. If the work tree's current branch is not in the .Dq refs/heads/ reference namespace, new commits may not be created on this branch. Local changes may only be committed if they are based on file content found in the most recent commit on the work tree's branch. If a path is found to be out of date, .Cm got update must be used first in order to merge local changes with changes made in the repository. .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 \(a~ 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 commands, 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 \(a~ 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 commands, 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 Oo Fl a Oc Oo Fl c Oc Op 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 descendant 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 which the work tree will remain switched to throughout the entire rebase operation. Commits on this branch 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 \(a~ 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 changes have been staged with .Cm got stage , these changes must first be committed with .Cm got commit or unstaged with .Cm got unstage . 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. If this option is used, no other command-line arguments are allowed. .It Fl c Continue an interrupted rebase operation. If this option is used, no other command-line arguments are allowed. .El .It Cm rb Short alias for .Cm rebase . .It Cm histedit Oo Fl a Oc Oo Fl c Oc Op Fl F Ar histedit-script Edit commit history between the work tree's current base commit and the tip commit of the work tree's current branch. .Pp Editing of commit history is controlled via a .Ar histedit script which can be edited interactively or passed on the command line. The format of the histedit script is line-based. Each line in the script begins with a command name, followed by whitespace and an argument. For most commands, the expected argument is a commit ID SHA1 hash. Any remaining text on the line is ignored. Lines which begin with the .Sq # character are ignored entirely. .Pp The available commands are as follows: .Bl -column YXZ pick-commit .It pick Ar commit Ta Use the specified commit as it is. .It edit Ar commit Ta Use the specified commit but once changes have been merged into the work tree interrupt the histedit operation for amending. .It fold Ar commit Ta Combine the specified commit with the next commit listed further below that will be used. .It drop Ar commit Ta Remove this commit from the edited history. .It mesg Ar log-message Ta Use the specified single-line log message for the commit on the previous line. If the log message argument is left empty, open an editor where a new log message can be written. .El .Pp Every commit in the history being edited must be mentioned in the script. Lines may be re-ordered to change the order of commits in the edited history. .Pp Edited commits are accumulated on a temporary branch which the work tree will remain switched to throughout the entire histedit operation. Once history editing has completed successfully, the temporary branch becomes the new version of the work tree's branch and the work tree is automatically switched to it. .Pp While merging 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 \(a~ Ta changes destined for a non-regular file were not merged .El .Pp If merge conflicts occur the histedit operation is interrupted and may be continued once conflicts have been resolved. Alternatively, the histedit operation may be aborted which will leave 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 histedit operation continues. .Pp .Cm got histedit will refuse to run if certain preconditions are not met. If the work tree's current branch is not in the .Dq refs/heads/ reference namespace, the history of the branch may not be edited. If the work tree contains multiple base commits it must first be updated to a single base commit with .Cm got update . If changes have been staged with .Cm got stage , these changes must first be committed with .Cm got commit or unstaged with .Cm got unstage . 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 edited history contains changes to files outside of the work tree's path prefix, the work tree cannot be used to edit the history of this branch. .Pp The .Cm got update command will refuse to run while a histedit operation is in progress. Other commands which manipulate the work tree may be used, and the .Cm got commit command may be used to commit arbitrary changes to the temporary branch while the histedit operation is interrupted. .Pp The options for .Cm got histedit are as follows: .Bl -tag -width Ds .It Fl a Abort an interrupted histedit operation. If this option is used, no other command-line arguments are allowed. .It Fl c Continue an interrupted histedit operation. If this option is used, no other command-line arguments are allowed. .El .It Cm he Short alias for .Cm histedit . .It Cm stage Oo Fl l Oc Oo Fl p Oc Oo Fl F Ar response-script Oc Op Ar path ... Stage local changes for inclusion in the next commit. If no .Ar path is specified, stage all changes in the work tree. Otherwise, stage changes at or within the specified paths. Paths may be staged if they are added, modified, or deleted according to .Cm got status . .Pp Show the status of each affected file, using the following status codes: .Bl -column YXZ description .It A Ta file addition has been staged .It M Ta file modification has been staged .It D Ta file deletion has been staged .El .Pp Staged file contents are saved in newly created blob objects in the repository. These blobs will be referred to by tree objects once staged changes have been committed. .Pp Staged changes affect the behaviour of .Cm got commit , .Cm got status , and .Cm got diff . While paths with staged changes exist, the .Cm got commit command will refuse to commit any paths which do not have staged changes. Local changes created on top of staged changes can only be committed if the path is staged again, or if the staged changes are committed first. The .Cm got status command will show both local changes and staged changes. The .Cm got diff command is able to display local changes relative to staged changes, and to display staged changes relative to the repository. The .Cm got revert command cannot revert staged changes but may be used to revert local changes created on top of staged changes. .Pp The options for .Cm got stage are as follows: .Bl -tag -width Ds .It Fl l Instead of staging new changes, list paths which are already staged, along with the IDs of staged blob objects and stage status codes. If paths were provided in the command line show the staged paths among the specified paths. Otherwise, show all staged paths. .It Fl p Instead of staging the entire content of a changed file, interactively select or reject changes for staging based on .Dq y (stage change), .Dq n (reject change), and .Dq q (quit staging this file) responses. If a file is in modified status, individual patches derived from the modified file content can be staged. Files in added or deleted status may only be staged or rejected in their entirety. .It Fl F Ar response-script With the .Fl p option, read .Dq y , .Dq n , and .Dq q responses line-by-line from the specified .Ar response-script file instead of prompting interactively. .El .Pp .Cm got stage will refuse to run if certain preconditions are not met. If a file contains merge conflicts, these conflicts must be resolved first. If a file is found to be out of date relative to the head commit on the work tree's current branch, the file must be updated with .Cm got update before it can be staged (however, this does not prevent the file from becoming out-of-date at some point after having been staged). .Pp The .Cm got update , .Cm got rebase , and .Cm got histedit commands will refuse to run while staged changes exist. If staged changes cannot be committed because a staged path is out of date, the path must be unstaged with .Cm got unstage before it can be updated with .Cm got update , and may then be staged again if necessary. .It Cm sg Short alias for .Cm stage . .It Cm unstage Oo Fl p Oc Oo Fl F Ar response-script Oc Op Ar path ... Merge staged changes back into the work tree and put affected paths back into non-staged status. If no .Ar path is specified, unstage all staged changes across the entire work tree. Otherwise, unstage changes at or within the specified paths. .Pp Show the status of each affected file, using the following status codes: .Bl -column YXZ description .It G Ta file was unstaged .It C Ta file was unstaged and conflicts occurred during merge .It ! Ta changes destined for a missing file were not merged .It D Ta file was staged as deleted and still is deleted .It d Ta file's deletion was obstructed by local modifications .It \(a~ Ta changes destined for a non-regular file were not merged .El .Pp The options for .Cm got unstage are as follows: .Bl -tag -width Ds .It Fl p Instead of unstaging the entire content of a changed file, interactively select or reject changes for unstaging based on .Dq y (unstage change), .Dq n (keep change staged), and .Dq q (quit unstaging this file) responses. If a file is staged in modified status, individual patches derived from the staged file content can be unstaged. Files staged in added or deleted status may only be unstaged in their entirety. .It Fl F Ar response-script With the .Fl p option, read .Dq y , .Dq n , and .Dq q responses line-by-line from the specified .Ar response-script file instead of prompting interactively. .El .It Cm ug Short alias for .Cm unstage . .El .Sh ENVIRONMENT .Bl -tag -width GOT_AUTHOR .It Ev GOT_AUTHOR The author's name and email address for .Cm got commit and .Cm got import , for example: .An Flan Hacker Aq Mt flan_hacker@openbsd.org . Because .Xr git 1 may fail to parse commits without an email address in author data, .Nm attempts to reject .Ev GOT_AUTHOR environment variables with a missing email address. .It Ev VISUAL , EDITOR The editor spawned by .Cm got commit . .It Ev GOT_LOG_DEFAULT_LIMIT The default limit on the number of commits traversed by .Cm got log . If set to zero, the limit is unbounded. This variable will be silently ignored if it is set to a non-numeric value. .El .Sh EXIT STATUS .Ex -std got .Sh EXAMPLES 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 Alternatively, for quick and dirty local testing of .Nm a new Git repository could be created and populated with files, e.g. from a temporary CVS checkout located at .Pa /tmp/src : .Pp .Dl $ got init /var/git/src.git .Dl $ got import -r /var/git/src.git -I CVS -I obj /tmp/src .Pp Check out a work tree from the 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 Interactively revert selected local changes in a work tree directory: .Pp .Dl $ got revert -p -R\ . .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 -f .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 Roll file content on the unified-buffer-cache branch back by one commit, and then fetch the rolled-back change into the work tree as a local change to be amended and perhaps committed again: .Pp .Dl $ got backout unified-buffer-cache .Dl $ got commit -m 'roll back previous' .Dl $ # now back out the previous backout :-) .Dl $ got backout unified-buffer-cache .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 .Pp Create a patch from all changes on the unified-buffer-cache branch. The patch can be mailed out for review and applied to .Ox Ns 's CVS tree: .Pp .Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff .Pp Edit the entire commit history of the .Dq unified-buffer-cache branch: .Pp .Dl $ got update -b unified-buffer-cache .Dl $ got update -c master .Dl $ got histedit .Pp Additional steps are necessary if local changes need to be pushed back to the remote repository, which currently requires .Cm git fetch and .Cm git push . Before working against existing branches in a repository cloned with .Dq git clone --bare , a Git .Dq refspec must be configured to map all references in the remote repository into the .Dq refs/remotes namespace of the local repository. This can achieved by setting Git's .Pa remote.origin.fetch configuration variable to the value .Dq +refs/heads/*:refs/remotes/origin/* with the .Cm git config command: .Pp .Dl $ cd /var/git/repo .Dl $ git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*' .Pp Alternatively, the following .Pa fetch configuration item can be added manually to the Git repository's .Pa config file: .Pp .Dl [remote "origin"] .Dl url = ... .Dl fetch = +refs/heads/*:refs/remotes/origin/* .Pp This configuration leaves the local repository's .Dq refs/heads namespace free for use by local branches checked out with .Cm got checkout and, if needed, created with .Cm got branch . .Pp Branches in the .Dq remotes/origin namespace can be updated with incoming changes from the remote repository with .Cm git fetch : .Pp .Dl $ cd /var/git/repo .Dl $ git fetch .Pp Before outgoing changes on the local .Dq master branch can be pushed to the remote repository, the local .Dq master branch must be rebased onto the .Dq origin/master branch: .Pp .Dl $ got update -b origin/master .Dl $ got rebase master .Pp Changes on the local .Dq master branch can then be pushed to the remote repository with .Cm git push : .Pp .Dl $ cd /var/git/repo .Dl $ git push origin master .Sh SEE ALSO .Xr tog 1 , .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 tasks, in particular tasks related to repository administration and tasks which require a network connection.