git, git/conf, git/query, git/walk, git/clone, git/branch, git/commit, git/diff, git/init, git/log, git/merge, git/push, git/pull, git/rm, git/serve – Manage git repositories.


git/add [ –r ] path...

git/branch [ –admns ] [ –b base ] newbranch

git/clone [ remote [ local ] ]

git/commit [ –re ] [ –m msg ] [ file... ]


git/conf [ –r ] [ –f file ] keys...

git/diff [ –c branch ] [ –s ] [ file... ]

git/export [ commits... ]

git/import [ commits... ]

git/init [ –b ] [ dir ] [ –u upstream ]

git/log [ –c commit | –e expr ] [ –n count ] [ –s ] [ files... ]

git/merge theirs

git/rebase [ –ari ] [ onto ]

git/pull [ –fq ] [ –u upstream ]

git/push [ –af ] [ –u upstream ] [ –b branch ] [ –r branch ]

git/query [ –pcr ] query

git/revert [ –c commit ] file...

git/rm path...

git/serve [ –w ] [ –r path ]

git/walk [ –qc ] [ –b branch ] [ –f filters ] [ file... ]


Git is a distributed version control system. This means that each repository contains a full copy of the history. This history is then synced between computers as needed.

These programs provide tools to manage and interoperate with repositories hosted in git.

Git stores snapshots of the working directory. Files can either be in a tracked or untracked state. Each commit takes the current version of all tracked files and adds them to a new commit.
This history is stored in the .git directory. This suite of git tools provides a file interface to the .git directory mounted on $repo/.git/fs. Modifications to the repository are done directly to the .git directory, and are reflected in the file system interface. This allows for easy scripting, without excessive complexity in the file API.


Git/init is used to create a new git repository, with no code or commits. The repository is created in the current directory by default. Passing a directory name will cause the repository to be created there instead. Passing the –b option will cause the repository to be initialized as a bare repository. Passing the upstream option will cause the upstream to be configured to upstream.

Git/clone will take an existing repository, served over either the git:// or ssh:// protocols. The first argument is the repository to clone. The second argument, optionally, specifies the location to clone into. If not specified, the repository will be cloned into the last path component of the clone source, with the .git stripped off if present.

Git/push is used to push the current changes to a remote repository. When no arguments are provided, the remote repository is taken from the origin configured in .git/config, and only the changes on the current branch are pushed. When passed the –a option, all branches are pushed. When passed the –u upstream option, the changes are pushed to upstream instead of the configured origin. When given the –r option, the branch is deleted from origin, instead of updated.

Git/revert restores the named files from HEAD. When passed the –c flag, restores files from the named commit.

Git/pull behaves in a similar manner to git/push, however it gets changes from the upstream repository. After fetching, it checks out the changes into the working directory. When passed the –f option, the update of the working copy is suppressed. When passed the –q option, the listing of changes is silenced. When passed the –u upstream option, the changes are pulled from upstream instead of the configured origin.

Git/serve serves repositories using the git:// protocol over stdin. By default, it serves them read–only. The –w flag, it allows pushing into repositories. The –r path flag serves repositories relative to path.

Git/fs serves a file system on $repo/.git/fs. For full documentation, see gitfs(4)

Git/add adds a file to the list of tracked files. When passed the –r flag, the file is removed from the list of tracked files. The copy of the file in the repository is left untouched.

Git/rm is an alias for git/add –r.

Git/commit creates a new commit consisting of all changes to the specified files. By default, an editor is opened to prepare the commit message. The –m flag supplies the commit message directly. The –r flag revises the contents of the previous commit, reusing the message. The –e flag opens an editor to finalize the commit message, regardless of whether or not it was specified explicitly or reused. To amend a commit message, –r can be used in conjunction with –m or –e.

Git/branch is used to list or switch branches. When invoked with no arguments, it lists the current branch. To list all branches, pass the –a option. To switch between branches, pass a branch name. When passed the –n option, the branch will be created, overwriting existing branch. When passed the –b base option, the branch created is based off of base instead of HEAD. When passed the –s option, the branch is created but the files are not checked out. When passed the –d option, the branch is deleted.

When switching branches, git/branch will refuse to clobber modifications. Passing the –m option will cause git9 to attempt to merge the changes between the branches.

Git/log shows a history of the current branch. When passed a list of files, only commits affecting those files are shown. The –c commit option logs starting from the provided commit, instead of HEAD. The –s option shows a summary of the commit, instead of the full message. The –n count option stops printing messages after count messages. The –e expr option shows commits matching the query expression provided. The expression is in the syntax of git/query.

Git/diff shows the differences between the currently checked out code and the HEAD commit. When passed the –c base option, the diff is computed against base instead of HEAD. When passed the –s option, only the file statuses are printed.

Git/export exports a list of commits in a format that git/import can apply.

Git/import imports a commit with message, author, and date information.

Git/merge takes two branches and merges them filewise using ape/diff3. The next commit made will be a merge commit.

Git/rebase takes one branch and moves it onto another. On error, the remaining commits to rebase are saved, and can be resumed once the conflict is resolved using the –r option. If the rebase is to be aborted, the –a option will clean up the in progress rebase and reset the state of the branch. The –i option will open an editor to modify the todo–list before the rebase begins.

The following rebase commands are supported:
pick    Apply the commit.
rewordApply the commit, then edit its commit message.
edit    Apply the commit, then exit to allow further changes.
squashFold the commit into the previous commit, then edit the combined commit message.
fixup   Fold the commit into the previous commit, discarding its commit message.
break   Exit to allow for manual edits or inspection before continuing.

Git/conf is a tool for querying the git configuration. The configuration key is provided as a dotted string. Spaces are accepted. For example, to find the URL of the origin repository, one might pass 'remote ??origin??.url'. When given the –r option, the root of the current repository is printed. Git/query takes an expression describing a commit, or set of commits, and resolves it to a list of commits. The –r option reverses the order of the commit list. With the –p option, instead of printing the commit hashes, the full path to their git/fs path is printed. With the –c option, the query must resolve to two commits. The blobs that have changed in the commits are printed.

Git/walk shows the status of files in the repository. It prints a list of paths prefixed with the status character. It exits with a non–empty status if the repository is not clean. The –c option suppresses the status, so only the paths are printed. The –q option suppresses all output. The –f option filters files by status, and only matching items are printed. By default, the filters are TRMA.

The status characters are as follows:
T     Tracked, not modified since last commit.
M     Modified since last commit.
R     This file will be gone in the next commit.
A     This file will be present in the next commit.
U     This file is not tracked by git.

Git/compat spawns an rc subshell with a compatibility stub in $path. This compatibility stub provides enough of the unix git commands to run tools like go get but not much more.


Refs are specified with a simple query syntax. A bare hash always evaluates to itself. Ref names are resolved to their hashes. The a ^ suffix operator finds the parent of a commit. The a b @ suffix operator finds the common ancestor of the previous two commits. The a .. b or a : b operator finds all commits between a and b. Between is defined as the set of all commits which are reachable from b but not reachable from a.


Git supports URL schemes of the format transport://dial/repo/path. The transport portion specifies the protocol to use. If the transport portion is omitted, then the transport used is ssh. The dial portion is either a plan 9 dial string, or a conventional host:port pair. For the ssh protocol, it may also include a user@ prefix. repo/path portion is the path of the repository on the server.
The supported transports are ssh://, git://, hjgit://, gits://, http://, and https. Two of these are specific to git9: gits:// and hjgit://. Both are the git:// protocol, tunneled over tls. Hjgit:// authenticates with the server using Plan 9 authentication, using tlsclient –a. Any of these protocol names may be prefixed with git+, for copy–paste compatibility with Unix git.


In order to create a new repository, run git/init:

git/init myrepo

To clone an existing repository from a git server, run:

cd harvey
# edit files
git/commit foo.c

To set a user and email for commits, run:

% mkdir $home/lib/git
% >$home/lib/git/config echo '
name = Ori Bernstein
email ='

The full git repository.
The configuration file for a repository.
The user–wide configuration for git. The contents of this file are used as fallbacks for the per–repository config.
The system–wide configuration for git. The contents of this file are used as fallbacks for the per–user config.

replica(1), patch(1), gitfs(4), diff3


Repositories with submodules are effectively read–only.

There are some missing commands, features, and tools.

git/compat only works within a git repository.