GitLab Documentation

GitLab Git Workshop


  1. Brief history of Git
  2. GitLab walkthrough
  3. Configure your environment
  4. Workshop

Git introduction


Use the tools at your disposal when you get stuck.

GitLab Walkthrough


Configure your environment

If it's not installed, it will prompt you to install it.

Git Workshop


  1. Configure Git
  2. Configure SSH Key
  3. Create a project
  4. Committing
  5. Feature branching
  6. Merge requests
  7. Feedback and Collaboration

Configure Git

One-time configuration of the Git client

git config --global "Your Name"
git config --global

Configure SSH Key

ssh-keygen -t rsa -b 4096 -C "you@computer-name"
# You will be prompted for the following information. Press enter to accept the defaults. Defaults appear in parentheses.
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/you/.ssh/id_rsa.
Your public key has been saved in /Users/you/.ssh/
The key fingerprint is:
39:fc:ce:94:f4:09:13:95:64:9a:65:c1:de:05:4d:01 you@computer-name

Copy your public key and add it to your GitLab profile

cat ~/.ssh/
ssh-rsa AAAAB3NzaC1yc2EAAAADAQEL17Ufacg8cDhlQMS5NhV8z3GHZdhCrZbl4gz

Create a project


mkdir ~/development
cd ~/development


mkdir ~/workspace
cd ~/workspace

git clone<username>/training-examples.git
cd training-examples

Git concepts

Untracked files

New files that Git has not been told to track previously.

Working area

Files that have been modified but are not committed.

Staging area

Modified files that have been marked to go in the next commit.


  1. Edit 'edit_this_file.rb' in 'training-examples'
  2. See it listed as a changed file (working area)
  3. View the differences
  4. Stage the file
  5. Commit
  6. Push the commit to the remote
  7. View the git log


# Edit `edit_this_file.rb`
git status
git diff
git add <file>
git commit -m 'My change'
git push origin master
git log

Feature branching

Feature branching

  1. Create a new feature branch called 'squash_some_bugs'
  2. Edit 'bugs.rb' and remove all the bugs.
  3. Commit
  4. Push


git checkout -b squash_some_bugs
# Edit `bugs.rb`
git status
git add bugs.rb
git commit -m 'Fix some buggy code'
git push origin squash_some_bugs

Merge requests

Merge requests

Create your first merge request

  1. Use the blue button in the activity feed
  2. View the diff (changes) and leave a comment
  3. Push a new commit to the same branch
  4. Review the changes again and notice the update

Feedback and Collaboration

Feedback and Collaboration

Review the Thoughtbot code-review guide for suggestions to follow when reviewing merge requests:

See GitLab merge requests for examples:

Explore GitLab projects




Additional resources


git checkout master

# Lightweight tag
git tag my_lightweight_tag

# Annotated tag
git tag -a v1.0 -m ‘Version 1.0’
git tag

git push origin --tags

Merge conflicts

Merge conflicts

  1. Checkout a new branch and edit conflicts.rb. Add 'Line4' and 'Line5'.
  2. Commit and push
  3. Checkout master and edit conflicts.rb. Add 'Line6' and 'Line7' below 'Line3'.
  4. Commit and push to master
  5. Create a merge request

Merge conflicts

After creating a merge request you should notice that conflicts exist. Resolve the conflicts locally by rebasing.

git rebase master

# Fix conflicts by editing the files.

git add conflicts.rb
git commit -m 'Fix conflicts'
git rebase --continue
git push origin <branch> -f

Rebase with squash

You may end up with a commit log that looks like this:

Fix issue #13
Fix again
Test again
Does this work?

Squash these in to meaningful commits using an interactive rebase.

Rebase with squash

Squash the commits on the same branch we used for the merge conflicts step.

git rebase -i master

In the editor, leave the first commit as 'pick' and set others to 'fixup'.



Thank you for your hard work!

Additional Resources

GitLab Documentation GUI Clients Pro git book Platzi Course Code School tutorial Contact Us -