Table of Contents



Why does Git exist? Why does it have the features it has? What problem does it solve? What motivates the design descisions?

Setup and configuration

Setup SSH connection

This is how to setup

# Generate SSH keys
ssh-keygen -t rsa -b 4096 -C ""

# Start the SSH daemon
eval "$(ssh-agent -s)"

# Register the newly generated private key
ssh-add ~/.ssh/id_rsa

# Test the connection


Global confiuration

GUI tools

Basic commands

git help

List all available git commands

git help -a

List all available git guides

git help -g

git checkout

Checkout an existing branch

git checkout master

Checkout a new branch

git checkout -b issue/additional-info#511

Checkout a branch from a remote repository

git checkout -b ACT-1333-upgrade upstream/ACT-1333-upgrade

Checkout an individual file

Checkout an individual file from another branch into the working tree of the current branch:

git checkout master -- scripts/


git push

Push a branch to a remote repository

Push a branch (issue/#512) to a remote repository (origin) and set a tracking reference (-u).

git push -u origin issue/#512

Delete a branch on a remote repository

Delete a branch (issue/additional-info#511) on a remote repository (orgin).

git push origin --delete issue/additional-info#511

git merge

Merge commit into current branch

Merge the given commit (issue/#512) into the current branch (dev):

git merge issue/#512

Resolve merge conflict

Resolve merge conflict with removed file ( and continue with the merge commit:

git add && git commit

Read more:

Abort failed merge

Abort after failed merge due to content conflicts:

git merge --abort

git diff

Show unstaged changes

git diff

Show staged changes

git diff --staged

Compare two commits

Shows the changes which were made between commit a (7ca9b3e) and commit b (0059976):

git diff 7ca9b3e..0059976

git log

Show the history of a path

git log -p pom.xml

Filter the history by commit messages

Show the history of all commits which contain the regular expression ([Ff]ix) in their commit message:

git log --grep=[Ff]ix

Show history as graph

The following command prints out the commit history on the terminal as text based graph:

git log --graph

git stash

Stash local modifications

Saves the local modifications away and reverts the working directory to match the HEAD commit.

git stash

Stash local modifications with a message

git stash save "test"

Print a list with all stashes

git stash list

Apply and delete the latest stash

git stash pop

Delete all stashes

git stash clear

git reset

Reset changes into staging area

git reset --soft 155b508

Reset changes into working tree

git reset --mixed 155b508

Discard changes

git reset --hard 155b508

Advanced features

Hosting Providers