image/svg+xml
Git Cheat Sheet
Front – Overview & Concepts
Resources
Git website http://git.or.cz/Cheat Sheet website http://jan-krueger.net/git
Branch A line of development to which changes can be made. Merging branches means that changes per- formed in one branch are transported into another. The most recent commit of a branch is called its tip and it can be referenced to a head. The default name of the development branch is master.Commit (a.k.a.: revision, version) A specific state in the branch's history. Each commit can be identified by a SHA hash and con- tains the hashes of its parents, i.e. the commit(s) it is based on, along with author information, a timestamp, and similar things. As a verb: record specific changes made to the working tree in the associated branch as a new state.Merge Transport changes in a branch into the current one. To merge from a remote branch, a copy of it must first be fetched. The combination of fetch and merge is called pull.Origin Indicates the default upstream repository, i.e. the (possibly remote) repository you cloned your local repository from. (This is actually called origin, i.e. no capital "o").Push Transport local changes to a remote repositoryRepository A combination of a working tree (not usually accessible from the outside) and a set of branches, some of which may be copies of remote branches. On a physical level, a repository is a directory con- taining a .git directory with repository metadata, and the files you are currently working on.Tag A name for a specific commit that never changes. This can be used to mark interesting versions of a branch, e.g. releases.
Terminology
This is version 2.0 of Jan Krüger's Git cheat sheet. Youcan contact the author by e-mail at: <jk@jk.gs>.
The Big Picture
Some Remote Repository
master branch
commits736f6d6574[...]7768617465[...]09f911029d[...]1f7e339700[...]
bar branch
baz branch
Your Working Repository
Working tree
bar.cdoc/foo.cquux.ctests/
master branch
commits6869207468[...]6769742072[...]09f911029d[...]1f7e339700[...]
commit
Branch currently checked out in working tree
Branch that can be checked out
foo branch
origin branch
quux branch
checkout
merge
fetch
push
reset
clone
Useful Tools
git Has all the standard operations as subcommands, e.g. branch, checkout, clone, commit, fetch, merge and so on.git-gui A graphical user interface for Git (Tk). Offers com- mands to commit, branch, merge etc.gitk Git's standard repository browser. Visualizes com- mits and such.git-web A web interface for viewing a Git repository. Ships with Git.
Getting started
New to the trade:1. This cheat sheet is not a tutorial. Read one!2. Since I already mentioned tutorials: the Git website has a lot of documentation.Switching from another system:3. Interoperability tools exist: Arch, CVS, SVN4. add/commit work differently than in most other SCM systems: add schedules changes for committing, commit records them. commit -a does both.5. Every working tree contains a full reposi- tory, unlike as in CVS or SVN.