Here are instructions on how to set up SSH and Git for GitLab. This is something you should only have to do once – after that you will be able to work smoothly with your laborations.
This guide requires you do to run commands in the terminal. Here is how open it:
You will use Git to synchronise your local work with the lab project on Chalmers GitLab. For this, you need an SSH key.
Start the terminal.
ssh-keygen
in the terminal, leaving all input prompts empty (including empty password).
It should print the path to your public key.
Look for something like:
Your public key has been saved in C:\Users\<username>\.ssh\id_<something>.pub
(on Mac/Linux it should be /<...>/.ssh/id_<something>.pub
instead).
.ssh
directory menioned above and view the contents of the text file id_<something>.pub
.
In the terminal, you can do this with cd; cd .ssh
and then cat id_<something>.pub
to print the file.
It should look something like this (the initial part may differ depending on settings):
ssh-ed25519 ...long-string-of-numbers-and-characters... user@computer
Go to SSH Keys on Chalmers GitLab and click on Add new key:
Copy the contents of the file from step 3 into the key textbox:
Give your key a title. We recommend you remove the expiration date. Click Add key to save.
ssh -T git@git.chalmers.se
.
You may be prompted to confirm the authenticity of the host (just answer “yes”).
The command should then print a welcome sentence:
Welcome to GitLab, @<username>!
If this does not work, most likely your key is in a location different from what SSH expects.
Run the same command with the option -v
and look for “identify file” to find out.
Here are more detailed. If you have any problems, ask a teaching assistant during lab supervision or online in the discussion channel of your course.
Git is the industry standard for version control and collaborative software development. It will pay off to become familiar with it! The student union also has a good introduction to Git.
Check if you have it installed by running git --version
; if it does not print an error, you have already it.
Otherwise, there are instructions for how to install it on your computer.
Set up your name and Chalmers/GU email:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Git will put this information into every commit you make to let other project members know who made it.
Note: If you use the Chalmers lab computers, you may experience a problem with git cloning. This is due to the following:
ssh-keygen
puts the key in your user folder on the C drive (in C:\...\.ssh\
).git
looks for your key in your Z drive (in Z:\.ssh\
).To solve this, just copy over the whole .ssh
directory from your user folder on the C drive to the Z drive.