Workshop on the basics of git
Will be held on 29th of January in 5416.0057 from 13:00 to 17:00
Go to file
Bastian dd9ca56626 add latest presentation 2020-01-29 16:11:09 +01:00
assignments Update assigment with slides 2020-01-16 11:53:36 +01:00
resources add latest presentation 2020-01-29 16:11:09 +01:00
.gitignore add gitignore 2020-01-14 16:41:17 +01:00 Add common terminal commands 2020-01-16 15:36:18 +01:00

How to Git started

This is the information provided for the git workshop held at the CIT on the 29th of January 2020.

Install Git

Download git for your operating system at:

You can use any GUI for git but to get a deep understanding of git we will use the terminal.
For available GUIs check out

Our remote git server is located at
You can log in with your usual p-number and password.

This README has been written in markdown.

To get an idea of how markdown works see the following cheat sheet: Markdown
We will not discuss markdown any further as this is beyond the scope of the workshop.

Learning objectives

  • Introduction to VCS
  • Create new repository
  • Git ignore file
  • Stage
  • Commit
  • Push / pull
  • Fork
  • Pull request
  • Branche
  • Merge / (Rebase)
  • Undoing Things
    • Amend commits
    • Unstaging
    • Unmodifying a modified file
    • Revert and reset
  • Log
  • Tag

Using the terminal

Configure tooling

Configure user information for all local repositories

$ git config --global "[name]"
# Sets the name you want attached to your commit transactions
$ git config --global "[email address]"
# Sets the email you want attached to your commit transactions
$ git config --global color.ui auto
# Enables helpful colorization of command line output
$ git config --global core.editor "nano" 
# Sets the default editor to nano

If you want to save your https credentials run

git config --global credential.helper store
Omit --global to set the identity only in this repository.

Or you can add an SSH key
The github description does also work for Gitea which we are using.

Check your config using

$ git config --list

Terminal commands

Common commands

  • cd: change directory
  • ls: list all the files
  • mkdir: make directory
  • rmdir: remove/delete directory
  • touch: create a file
  • rm: remove a file
  • pwd: find out the file path of current directory you are in, from the root

See changes that have been made

git diff

Adding files to commit

git add file1 file2
git add *

Committing files with commit message, this will stage your changes

git commit -m "your commit message"

unstage by using

use "git reset HEAD <file>..." to unstage


Branches are an important part of working with Git.
Any commits you make will be made on the branch youre currently “checked out” to.
Use git status to see which branch that is.

Creates a new branch

$ git branch [branch-name]
$ git checkout -b [branch-name]

Switches to the specified branch and updates the working directory

$ git checkout [branch-name]

Combines the specified branchs history into the current branch. This is usually done in pull requests, but is an important Git operation.

$ git merge [branch]

Deletes the specified branch

$ git branch -d [branch-name]

Show all available branches

git branch -a

Track remote branch

git checkout --track origin/<branch>

Delete remote branch

git push <remote_name> --delete <branch_name>
git remote prune <remote_name>

Check the log in graph form

git log --graph --oneline


  • git: an open source, distributed version-control system
  • GitHub: a platform for hosting and collaborating on Git repositories
  • commit: a Git object, a snapshot of your entire repository compressed into a SHA
  • branch: a lightweight movable pointer to a commit
  • clone: a local version of a repository, including all commits and branches
  • remote: a common repository on GitHub that all team members use to exchange their changes
  • fork: a copy of a repository on GitHub owned by a different user
  • pull request: a place to compare and discuss the differences introduced on a branch with reviews, comments, integrated tests, and more
  • HEAD: representing your current working directory, the HEAD pointer can be moved to different branches, tags, or commits when using git checkout