GIT(1) GIT(1)
NAME
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.
SYNOPSIS
git/add [ -r ] path...
git/branch [ -admns ] [ -b base ] newbranch
git/clone [ remote [ local ] ]
git/commit [ -re ] [ -m msg ] [ file... ]
git/compat
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(1) GIT(1)
DESCRIPTION
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.
CONCEPTS
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 script-
ing, without excessive complexity in the file API.
COMMANDS
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, option-
ally, specifies the location to clone into. If not speci-
fied, the repository will be cloned into the last path com-
ponent 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(1) GIT(1)
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 sup-
pressed. 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 docu-
mentation, 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 conjuction 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.
GIT(1) GIT(1)
When switching branches, git/branch will refuse to clobber
modificiations. 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 pro-
vided. 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 commmit.
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.
reword Apply the commit, then edit its commit message.
edit Apply the commit, then exit to allow further
changes.
GIT(1) GIT(1)
squash Fold the commit into the previous commit, then
edit the combined commit message.
fixup Fold the commit into the previous commit, discard-
ing 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 reposi-
tory, one might pass
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 provides a tool for walking the list of tracked
objects and printing their status. With no arguments, it
prints a list of paths prefixed with the status character.
When given the -c character, only the paths are printed.
When given the -q option, all output is suppressed, and only
the status is printed. When given the -f option, the output
is filtered by status code, and only matching items are
printed.
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.
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.
GIT(1) GIT(1)
REF SYNTAX
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 com-
mit. 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 reach-
able from a.
PROTOCOLS
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,
tunnelled 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.
EXAMPLES
In order to create a new repository, run git/init:
git/init myrepo
To clone an existing repository from a git server, run:
git/clone https://github.com/Harvey-OS/harvey
cd harvey
# edit files
git/commit foo.c
git/push
To set a user and email for commits, run:
% mkdir $home/lib/git
% >$home/lib/git/config echo '
[user]
name = Ori Bernstein
email = ori@eigenstate.org'
GIT(1) GIT(1)
FILES
$repo/.git
The full git repository.
$repo/.git/config
The configuration file for a repository.
$home/lib/git/config
The user-wide configuration for git. The contents of
this file are used as fallbacks for the per-repository
config.
/sys/lib/git/config
The system-wide configuration for git. The contents of
this file are used as fallbacks for the per-user con-
fig.
SEE ALSO
replica(1), patch(1), gitfs(4), diff3
BUGS
Repositories with submodules are effectively read-only.
There are some missing commands, features, and tools.
git/compat only works within a git repository.