- Infos im HLRS Wiki sind nicht rechtsverbindlich und ohne Gewähr -
- Information contained in the HLRS Wiki is not legally binding and HLRS is not responsible for any damages that might result from its use -

Git: Difference between revisions

From HLRS Platforms
Jump to navigationJump to search
Line 88: Line 88:
}}
}}


Due to the fact that internet access is restricted within HWW-systems, you have to use a [[Secure_Shell_ssh#Git | ssh tunnel]] to access remote repositories.
 
<font color=red>Due to the fact that internet access is restricted within HWW-systems, you have to use a [[Secure_Shell_ssh#Git | ssh tunnel]] to access remote repositories.</font color>


[[Category:Revision Control]]
[[Category:Revision Control]]

Revision as of 13:15, 4 February 2018

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
Platforms:
Category: Revision Control
License: General Public License (version 2)
Website: Git homepage


Usage

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


Branches

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.

A very nice GUI to keep a general view of your branches and their relationship is

gitk


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 create a svn directory tracked via git with

git svn init [options] URL


To check out the svn director and rebase the currently checked out git branch via

git svn fetch git svn rebase


To commit changes from a git branch to the svn repository use

git svn dcommit


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

git help svn


Usage on HWW/HLRS platforms

In order to use git on our platforms Hazelhen, Laki and Kabuki, load the corresponding module

module load tools/git


Due to the fact that internet access is restricted within HWW-systems, you have to use a ssh tunnel to access remote repositories.