Setting Up
Dags att installera Git och bekanta oss med GitLab. Tobias guidar oss!
Step 1: Install Git
Download and install the latest version of Git from https://git-scm.com/downloads. You can find further information at Getting started - installing Git
Step 2: Open a terminal window
Select your operating system.
Windows
These instructions are given using Bash, luckily Bash gets installed with Git. Search for, and open Git Bash.

macOS
These instructions are given using Bash, luckily it is the default in macOS. To open a Terminal using Spotlight press ⌘ + space and search for terminal.
Can't find it? Take a look at How to Get to the Command Line on a Mac.
Recommended reading: How to use Terminal on Mac.
Linux
These instructions are given using Bash, luckily it is already pre-installed. Search for, and open terminal.
Can't find it? Take a look at How to Open a Terminal Window in Ubuntu.
New to Bash? Take a look at Basics of Bash for beginners.
Step 3: Check your Git version
To check your Git version run the command git --version in your Terminal.
git --version
Depending on your Git version the output should look something like this:
git version 2.21.0
Step 4: Show configurations
List your current Git configuration using the command git config --list:
git config --list
If the output is a list of configurations it means that everything is working as expected and you can continue.
Example output:
core.symlinks=true
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
diff.astextplain.textconv=astextplain
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.required=true
filter.lfs.process=git-lfs filter-process
On MacOS, the line "credential.helper=osxkeychain" might apear as the first line
Step 5: Add your name
Add the name you want to be connected to your changes.
git config --global user.name 'Your Name'
:warning: Replace Your Name with your actual name.
You can read more about this at Setting your username in Git.
Step 6: Verify the name change
You should get your name as output when you run:
git config --global user.name
Step 7: Add you email
It is important that you add your student email.
git config --global user.email 'st123id@student.lnu.se'
:warning: Replace st123id with your student id.
You can read more about this at Setting your email in Git.
Step 8: Verify the email change
You should get your email as output when you run:
git config --global user.email
Step 9: Add alias for gitignore.io (optional)
This step and step 10 and 11 are optional and you can skip them if you want.
Usually, there are somethings that you don't want to be tracked by Git. It might be files from your operating system, node modules or secrets like passwords or access tokens. The way to inform Git about which files that should be ignored you have to create a .gitignore file. Perhaps the easiest way is to use gitignore.io.
To make it even easier you should create an alias (shortcut) for using it.
git config --global alias.ignore '!gi() { curl -L -s https://www.gitignore.io/api/$@ ;}; gi'
Step 10: Verify that the alias has been added (optional)
git config --get-regexp ^alias\.ignore
Expected result:
alias.ignore !gi() { curl -L -s https://www.gitignore.io/api/$@ ;}; gi
Step 11: Make sure the alias works (optional)
Run:
git ignore
Expected result:
gitignore.io help:
list - lists the operating systems, programming languages and IDE input types
:types: - creates .gitignore files for types of operating systems, programming languages or IDEs
Step 12: Add SSH
Secure Shell (SSH) is a cryptographic network protocol that allows for secure data communication over an unsecured network. When working with Git and GitLab, SSH provides several advantages:
Secure Communication: SSH encrypts the data transferred between your local machine and the GitLab server. This ensures that your code, as well as any sensitive information, remains confidential and is not easily intercepted by malicious actors.
Password-less Authentication: Once you set up SSH keys, you won't need to enter your username and password every time you push or pull from the repository. This not only speeds up the workflow but also reduces the risk of exposing your credentials.
Identity Verification: SSH keys work in pairs - a private key that remains on your machine and a public key that you upload to GitLab. When you try to connect, GitLab uses these keys to verify your identity. This two-key system ensures that only someone with the corresponding private key can access the repository.
Streamlined Workflows: For developers who frequently interact with their repositories, entering credentials every time can be cumbersome. SSH key authentication streamlines this process, making it smoother and more efficient.
Enhanced Collaboration: In teams, different members can have their own SSH keys. This allows for easy tracking of who made changes, ensuring accountability and better collaboration.
Adding SSH for GitLab in Short:
Generate SSH Key Pair: On your local machine, use the ssh-keygen command to generate a new SSH key pair. This will create two files: a public key (typically named
id_rsa.pub) and a private key (id_rsa).Copy Public Key: Open the
id_rsa.pubfile with a text editor and copy its entire content.Add to GitLab:
- Log in to your GitLab account.
- Navigate to your profile settings.
- Go to the "SSH Keys" section.
- Paste your copied public key into the provided text box and save.
- Test Connection: In your terminal or command prompt, type
ssh -T git@gitlab.lnu.seto test the connection. If successful, you'll receive a welcome message from GitLab.
For detailed steps and troubleshooting, please refer to the official GitLab documentation..
Step 13: All done!
You're now done to use Git and Gitlab. If you're new to Git and/or Bash, please take a look at the following resources to make your life easier.
- Videos - a couple of short videos that introduce you to the basics of Git.
- Pro Git - free online book.
- Learn Git in 15 minutes - an informative video by Colt Steele.
- Reference manual
- Basics of Bash for beginners