Version Control Workshop


Linux User Group FH Hagenberg


Reasons to Use Version Control

When Not?


Stores complete history, branches, tags
Working Copy
Your “playground”, actual source code
Commit / Revision
A single version
A separate line of development

Centralized Version Control

Distributed Version Control


Git, the information manager from hell


Install & Setup

# apt-get install git gitk
$ git config --global 'Daniel Knittl-Frank'
$ git config --global 'S1010454…'

$ git config --global core.autocrlf false

Creating repositories

$ cd path/to/project
$ git init

$ git init new_dir
$ cd new_dir

Adding files

$ >foo echo 'bar'
$ git add foo

Writing history

$ git commit
Initial commit for workshop

Here follows a longer description of what the commit did. In our case, we simply added a file for demonstration purposes.

Updating files

$ >>foo echo 'new content'
$ git add foo
$ git commit -m 'Updated file'

Browsing history

$ git log
commit 7d266f1981b3156784a17a44ef7b46a62c72a21c

Author: Daniel Knittl-Frank <S1010454…>
Date:   Sun Feb 26 18:21:51 2012 +0100

    Updated file

commit 01d9322c973c5055ec630a7e9120ac90f6862269

Author: Daniel Knittl-Frank <S1010454…>
Date:   Sun Feb 26 18:21:31 2012 +0100

    Initial commit for workshop
    Here follows a longer description …

Working Copy Status

$ git status
# On branch master
nothing to commit (working directory clean)

Inspecting changes

$ git diff
$ git diff HEAD^ HEAD
$ git diff branch1 branch2

Branching history

$ git branch newbranch
$ git checkout newbranch

$ git branch
* newbranch

Merging changes

$ git merge newbranch

Resolving merge conflicts

$ cat foo
<<<<<<< HEAD
current content
branch content
>>>>>>> newbranch

$ vim foo
$ git add foo
$ git commit

Forking existing projects

$ git clone git:// git
$ cd git
$ git fetch
$ git pull


$ git pull git:// feature

$ git remote add repo git://
$ git pull repo feature

Publishing your projects

$ ssh user@server
$ git init --bare /path/to/repo
$ logout
$ git push user@server:/path/to/repo

Graphical Clients / Frontends