First time Git setup for RSP course

2.6.1. First time Git setup for RSP course#

The steps in this section you should only have to do once, and help configure Git your computer and to register you with this course’s gitlab server. Let’s do this before you learn the Git commands.

As a very first step, we must make sure that you have logged into our course’s gitlab server once such that your TU Delft netid is registered and we can add you to the gitlab repository that we created for your lab group. This step will only need to be done once at the start of this course.

Exercise 2.73

Log in once to https://gitlab.ro47003.me.tudelft.nl/

Note: until we have added you to a lab group, you might not see anything in this gitlab repository.

To make working with gitlab more convenient, you should create an public/private SSH key pair, and add the public key to your gitlab account. This enables you to push and pull from your PC without entering your username and passphrase every single time. The private part of the key pair will remain on your computer, and your computer will use it to identify itself to the Gitlab server. The server will compare the private key of your computer to the public key you added to your Gitlab profile, and only accept your Git push and pull requests if the keys match.

Note that both you and your partner must do this on your own account, so that you both have your own credentials and identity when pushing new commits to the repository. Important: SSH keys are personal and you will tie it to your Gitlab profile associated with your TU Delft netid, so do not share your private key with anyone, including your lab partner. You can always revoke keys that may have been compromised on your gitlab account page.

Exercise 2.74

Add an SSH key to your gitlab account on our course’s server. Note that this only needs to be done once, unless you delete your SSH keys or start using a new Linux system during the course, in which case you will need to generate a new key pair and add that to your Gitlab profile.

Follow the instructions at https://gitlab.ro47003.me.tudelft.nl/help/user/ssh.md on how to generate a new SSH key pair, and on how to add the SSH key to your gitlab account.

Note:

  • It is recommended you use the default file name to save the key (just press Enter when it asks you for a file name to save the key), because then the key will automatically be found when needed.

  • To avoid needing to activate the key every time you push or pull to a Gitlab repo, do not create a pass phrase for the key pair (again, just press Enter when prompted). In general it is a good security measure to use pass phrases, but if you saved the key pair in your local Linux user account, which has its own login password, then there is little risk for misuse during this course.

  • You should only add the new public key (in the generated key file with the .pub extension) to your your Gitlab user profile’s SSH Keys page, as explained in the Gitlab SSH instructions page linked above.

If this is the first time that you use Git on your PC, you also need to tell Git your user name and email. This information will occur in the author information of any Git commit that you make on this computer.

Configuring git can be done using git config, you will some example uses throughout this computer. The command takes an optional argument --global to make a Git configuration option part of Git’s ā€œglobalā€ configuration, which you can think of as a default configuration that applies to every Git repository on your computer, unless a repository explicitly specifies its own more specific ā€œlocalā€ configuration options. Using git config without --global would set options on the current local Git repository in your current working directory.

Exercise 2.75

Type the following in your terminal, where you replace <First Last> with your first and last name in " quotes, and <Email> with your TU Delft email address in " quotes.

$ git config --global user.name <First Last>
$ git config --global user.email <Email>

This will update your global Git configuration options on your computer.