Deprecation notice:
git@ifflinux can still be used to host Git repositories. However, for new projects we recommend to use our newer GitLab server (https://iffgit.fz-juelich.de/). GitLab offers a web-based user interface for creating and managing projects and adds many extras on top of Git like continuous integration.
Visit the GitLab documentation website to learn more about GitLab basics. Our GitLab CI example project helps to adopt GitLab CI techniques for your own projects.
Git repositories can be hosted on our gitolite3 server, git@ifflinux. Authentication is handled via your fz-juelich.de email address and a public ssh key. To be added to the server or create a git repository, send an email to f.rhiem@fz-juelich.de or i.meyer@fz-juelich.de, containing your public key and - if applicable - information on the git repository you want to work on.
If you do not have a ssh key pair yet (there are no id_rsa files in your ~/.ssh directory), you can create one with the following command:
ssh-keygen -b 4096 -t rsa -C<your-mail-address>
As a result you will get two files, one with a .pub file ending and one without any extension. Please send only the pub file to us. The other file contains the private counterpart that is only for you.
Important!
Please always create key pairs that are password protected (you will be asked for a password during the key creation process). Keys without password encryption are not accepted for our git server. However, in order to prevent retyping passwords often, you can use the ssh agent (linux) or a key chain (Mac OS X) to keep your password in memory as long as you are logged in on your machine.
You can use ssh git@ifflinux info
to check your account status on the
server and you can find an overview of other commands in our gitolite3 cheat
sheet.
Notice for users of multiple ssh keys:
Git (or rather ssh) tries to read the primary key ~/.ssh/id_rsa by default. If you generated a further key only for git usage, you should create a ssh config file which binds that key to the git server (~/.ssh/config):
Host iffgitolite HostName ifflinux.iff.kfa-juelich.de User git IdentityFile ~/.ssh/<key_name>After creating the config file the git server can be referenced with iffgitolite without a user name, for example:
ssh iffgitolite info
.
Quick Introduction to Git
This section introduces the most important git commands for a day-to-day use. For a more comprehensive guide to git checkout our git talk.
Cloning:
Before you can start working your newly created git repository on ifflinux has to be cloned on your local machine:
git clone git@ifflinux:<project-name>
If you started to work with git on a project before the central repository on ifflinux was created, you can add the central repository as a remote reference to your existing local repository as follows:
git remote add origin git@ifflinux:<project-name>
Adding new files to your project:
New files and directories can be added with the git add command:
git add <files/directories>
git add operates recursively, so all subdirectories are added as well.
Important:
git add does not work on empty directories since git is a file-based version control system. As a workaround you can place an empty .gitkeep file into that directory.
Save your current working progress:
Creating a commit will save your working progress and can be synchronized with the central git server afterwards. Additionally, it's possible to reuse that code base at a later time.
git commit -a -m "Commit-Message"
The -a switch is important to automatically include all files that were modified since your last commit.
Transfer your commits to the central server:
git commit -a only creates a local save point. In order to transfer it to the central git installation you run:
git push -u origin master
origin is the name of the server you cloned from.
master is the default git branch you are working on. Branches can be used to develop new features parallel in time but for a simple workflow it is not strictly necessary that you know about them.
The option -u creates an upstream reference. From now on git knows that your local and the remote branch belong together and in the future you can simply type:
git push
without any arguments.
Fetch data from the central server:
Commits that your colleagues pushed to the server can be obtained via:
git pull
The progress from the server is automatically merged with your local work.
If you have further questions, you are welcome to send a mail to i.meyer@fz-juelich.de.