© github octocat

Why git?

Hmm, which one is the latest version?

Does this trigger flashbacks?

What git[-hub, -lab, ...] does

  • Saves lots of previous versions of your work
  • Manages them smartly (and lets you do extra tricks)
  • Lets you share a current working version with your collaborators
  • or synchronize your work on your working places
  • Different people can work on the same file seamlessly

No need to bounce "here's the new version" e-mail messages and combine files manually (with the risk of losing your work)

What is needed is a server that hosts the database

  • Try gitlab - the csc internal server
  • Try github - a popular social website for open source projects that comes with lots of innovative features
  • Try bitbucket - another popular service that offers private repositories

Configure git

My config file ~/.gitconfig:

    name = highlando
    email = jnhlnd@gmail.com
    ui = auto
    diff = auto
    status = auto
    branch = auto
    ci = commit -am 
    tool = gvimdiff 


Example on github

If you have never seen github, take a look at any repository you like, for example KryPy.

Live demo

  • Upload ssh public key to github
  • Create a repository on github
  • Clone the repository to your machine
  • Modify files, diff
  • Add files, commit
  • Push, pull
  • Watch commits, diffs on github

Best working practice

1 logical change → 1 commit!

Do not try to fix all bugs in one monster commit!

Example commit messages:

  • Introduction rewritten
  • Notation in section 2 changed
  • Fixed typo
  • Fixed nasty bug that ruined my weekend


  • Two persons edit different files → OK
  • Two persons edit different parts of the same file → OK
  • Two persons make the exact same modification → OK
  • Two persons make different modifications in the same place → conflict

git cheatsheet: once-per-project commands

Get a project from a server

clone remote repo git clone git@github.com:andrenarchy/krypy.git

or create it locally and put it on the server...

create empty repo git init
link to remote repo git remote add origin git@github.com:andrenarchy/krypy.git
first push git push -u origin master

git cheatsheet: every day commands

pull changes from remote git pull
show changes in all files git diff
show changes in specified files git diff paper.tex gmres.py
overview of changes git status
add specified files for commit git add paper.tex gmres.py
commit to local repo git commit
commit all changes to local repo git commit -a
push commits to remote repo git push
show last commit messages git log
revert a file to last commited state git checkout paper.tex

git cheatsheet: further commands

Shortcut: commit all and add message git commit -am 'message'
HELP! show help for command CMD git CMD --help
list all branches git branch
create branch andre_hack git branch andre_hack
create version tag release2.3 git tag release2.3

Thank you!