Setting up Git

Git

Context

In order to work locally on the repositories and their content hosted at the ASAM GitLab, users can install and set up Git on their local computer. Git can also interface directly with VSCode, making changing and updating files from within one tool an easy option.

Result

  • Git is installed locally.

  • Git credentials (SSH) is configured

Prerequisites

  • For direct integration: VSCode is installed

How

Git requires a multi-step installation. The following sections describe each part of this setup sequentially.

Install Git

  1. If you are unsure if git is installed, you can check by entering the following in a shell window and confirming:

    git --version

    If a git version is returned, git is already installed on your system.

  2. If git is not installed, follow the instructions on how to install git

Configure user credentials

After installation of Git, configure your user credentials that Git uses when checking in changed content from your PC to the ASAM GitLab. To make sure your commits match your name and email details, a one time configuration is necessary.

  1. Open a shell or terminal window

  2. Execute the following command and replace the entries "FIRST_NAME, LAST_NAME" accordingly:

    git config --global user.name "FIRST_NAME LAST_NAME"
    Example 1. Setting git user name for Max Mustermann
    git config --global user.name Max Mustermann
  3. Next, execute the following command and replace the entry "MY_NAME@example.com" with your comany’s email:

    git config --global user.email "MY_NAME@example.com"
    Example 2. Setting email for Max Mustermann working at company
    git config --global user.email max.mustermann@company.com
    If no error is returned, the configuration step has been successful.

OPTIONAL: SSH Key Pair

To ensure you don’t have to enter your login details every time you want to interact with the repository, add an SSH key to your account.

  1. Generate an SSH key pair following the official instructions.

    Entering a passphrase is optional and leads to additional steps every time you connect to the remote, so it is not recommended.
  2. Add the generated SSH public key to your GitLab account by following these instructions.

  3. Verify that you can connect

Troubleshooting / Known Issues

I cannot click Next after selecting 'Visual Studio Code' as Git’s default editor during installation

If you cannot click Next, make sure Visual Studio Code is already installed. Return to the previous step and continue again. Now, the Next button should be active.

My SSH keys are not working

Make sure that the ssh-agent is running:

  1. Open a shell or terminal window

  2. Type the following command, hit Enter, and check the status:

    Get-Service ssh-agent
    1. If the status is "Stopped", type the following, hit Enter, and check the StartType.

      Get-Service ssh-agent | Select StartType
    2. If the StartType is "Disabled", activate the SSH Agent. See My SSH agent is deactivated.
      Continue here after your SSH agent has bee activated.

  3. Enter the following command and hit Enter

    Start-Service ssh-agent

My SSH agent is deactivated

This requires administration rights. If you do not have these, request support from your IT department.
  1. Open a shell or terminal window with Administration rights

  2. Set the SSH Agent to start manually by typing the following command and hitting Enter:

    Get-Service -Name ssh-agent | Set-Service -StartupType Manual

I cannot add my private key to the SSH agent

This cannot be done in the Administration terminal window if your Admin account is not your user account! Otherwise, Windows will complain about unprotected private key files! Switch to a non-administrator PowerShell and execute the command again.