/ informatics / tools /



Git is an open-source version control system. It is used to manage a set of files, as they change over time.


Repository: It is stored in the same directory as the project itself, in a subdirectory called .git.

Commit Object

A Commit Object is a set files. It can be referred by its partial or full SHA1 name or relative to a head. The postfix ^ refers to the parent of a head.

Head: simply a named reference to a commit object. By default, there is a head in every repository called master.



The index (= Stage = Cache)


Tags are pointers to a certain commit. They use a name which is more memorizeable than the hash of the commit.

Creating and Cloning

There are two ways to create a repository:

  1. Online: You create the repository on the website (e.g. github.com) and afterwads clone the empty repository with git clone git://...
  2. Offline: You create a new repository in the current directory with git init

Diagnose and Information

git status lists modified and untracked files
git diff HEAD shows changes between working dir and HEAD

Commiting Changes

Merge master into feature branch

git fetch origin master:master
git rebase master
git push -f

Repairing and Restoring

Undo changes

Recover deleted files

git rev-list -n 1 HEAD -- <file>
git checkout <commit>^ -- <file>