Git guides

Git

Make changes in a repository

Git workflow

It is best practice to check for changes on remote before changing files locally and before pushing changes to remote.

The Git workflow for making changes is a 4 step process:

Git Workflow
Figure 1. Git workflow
  1. Make the changes in your working copy.

  2. Add files from the working copy to the staging area (git add).

  3. Commit staged files to your local repo (git commit).

  4. Push to a remote repository (git push).

Cloning a repository

If you want to work on a repository locally, you need to first check it out from remote (GitLab). To do so, follow one of the cloning instructions below.

If your project contains submodules, make sure to also update them.
  • Terminal

  • VSCode

  • Gitlab-to-VSCode

  1. Find the repository url on the website and copy the git url

  2. Open the folder on your PC where you want to save the repository

  3. Open the Git Bash from the Context Menu (right-click → Select "Git Bash Here")

  4. Type git clone --recurse-submodules and then press the middle mouse button to paste the copied url. Confirm with Enter

    With this command, you do not need to manually initialize the submodules after checkout!
Alternatively to the Git Bash, you can also use the terminal with the same commands. Make sure to open your Powershell in your directory, though.
clone by git bash
This only needs to be done once to obtain a local copy.
  1. Find the repository url on the website and copy the git url

  2. Open the Command Pallette (Ctrl+Shift+P), type Git: Clone, then press Enter

  3. Paste the copied git url and press Enter

  4. Select the folder on your PC where you want to save the repository

gitlab clone ssh
If you encounter an error that the host key verification failed, you need to add GitLab to your known_host file.
git error host key verification failed
  1. Click Clone  Visual Studio Code

  2. Select the folder on your PC where you want to save the repository

clone to vscode