- Infos im HLRS Wiki sind nicht rechtsverbindlich und ohne Gewähr -


From HLRS Platforms
Jump to navigationJump to search
Git is a distributed version-control system initiated by Linus Torvalds in 2005. It allows local and remote repositories to store the development history of any kind of documents. It's strengths are its speed, low disk space requirements because of compression techniques as well as failure resistance and built in security because of it's hash based approach.
Developer: Junio Hamano, Linus Torvalds, and many other
Category: Revision Control
License: General Public License (version 2)
Website: Git homepage


The basic concept of Git uses three levels: Working directory, index and repository. While the working directory is the place the user makes changes, the repository stores the history of changes. The index is used to prepare a new history entry before committing to the repository.

In general Git has a very good help system which provides all the information required including lots of examples and workflows.

git help git git help COMMAND

To start version control on a directory (and it's sub-directories) execute inside the directory the following command:

git init

This will create a .git directory which will store all configuration data (including the index) and the repository itself.

Commiting changes to your newly created repository is a two state process: First changes have to be added to the index and then the index has to be committed to the repository:

git add my_new_file my_changed_file ... git commit

You can view the current status of your working directory and index with

git status

Several GUI tools exist which ease up this process. Just try out

git gui


Git makes it very easy to handle branches, merge changes and distribute data. In Git branches are very cheap so use them for every small change you make in your code! To create a new branch just do a

git branch NAME

To see the current branch use

git branch

To switch to another branch use

git checkout BRANCH

Note, that git will refuse to change to another branch if any changes may be lost.

Remote repositories

Git is a distributed version control system. This means that it does not rely on a single global repository but on multiple repositories from multiple users - which have all different repositories. This concept means that you only include from other repositories the data/branches you need or want to merge.

If you want to clone a git repository (or another local git repository) use

git clone URL/PATH

To get the latest changes from the repository use

git fetch

To merge the changes automatically to your working tree use

git pull

If you are allowed to write to the remote repository you can push your changes to a remote repository with

git push

Git and Subversion (SVN)

For Git a very nice plugin for subversion exists. It allows to check out and commit changes to a remote svn directory while holding a local git repository.

You can checkout a svn directory with

git svn init [options] URL git svn fetch git svn rebase

Have a look on the help system for the svn command as a lot of options exist:

git help svn