- 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
(5 intermediate revisions by 2 users not shown) | |||
Line 80: | Line 80: | ||
{{command|command=git help svn}} | {{command|command=git help svn}} | ||
== Usage on HWW/HLRS platforms == | |||
In order to use Git on our platforms Hazelhen, Laki and Kabuki, load the corresponding module | |||
{{Command | command = | |||
module load tools/git | |||
}} | |||
<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]] |
Latest revision as of 13:17, 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. |
|
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.
To start version control on a directory (and it's sub-directories) execute inside the directory the following command:
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:
You can view the current status of your working directory and index with
Several GUI tools exist which ease up this process. Just try out
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
To see the current branch use
To switch to another branch use
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
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
To get the latest changes from the repository use
To merge the changes automatically to your working tree use
If you are allowed to write to the remote repository you can push your changes to a remote repository with
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
To check out the svn director and rebase the currently checked out git branch via
To commit changes from a git branch to the svn repository use
Have a look on the help system for the svn command as a lot of options exist:
Usage on HWW/HLRS platforms
In order to use Git on our platforms Hazelhen, Laki and Kabuki, load the corresponding module
Due to the fact that internet access is restricted within HWW-systems, you have to use a ssh tunnel to access remote repositories.