An introduction to Git

Presenter Notes

About me

Nelle Varoquaux

CBIO Mines ParisTech, U900 Institut Curie, INSERM

Presenter Notes

Why do I need version control ?

As researchers, you want:

  • reproducible research
  • fast and efficient research

Presenter Notes

A story told by filenames


"Piled Higher and Deeper" by Jorge Cham:

Presenter Notes

Version control

Version control system:

  • keeps all the historical versions for easy tracking.
  • benefits team collaboration.
  • improves our efficiency.

Presenter Notes

Setting up Git

Presenter Notes

Creating a project

  • Initializing a new project::

    $ git init

    Initialized empty Git repository in /home/nelle/Projets/SCBC/git-test/.git/

  • Initializing from an existing project::

    $ git clone git://

Presenter Notes

Configuring Git

  • Locally: only the git repository you are working on will be affected::

    git config [options]

  • User-wide: the user's default configuration will be modified in ~/.git/config::

    git config --global [options]

  • Globally: system-wide configuration: all users are going to be affected::

    git config --system [options]

Presenter Notes

Configuring git

  • Your identity::

    $ git config --global "Your Name Comes Here"

    $ git config --global

  • Setting your editor::

    $ git config --global core.editor vim

  • Checking your settings::

    $ git config --list

Presenter Notes

Saving snapshots

Presenter Notes

A few commands

  • git add: adds a file to the snapshot we want to take::

    $ git add README

  • git commit: save all the files we added to the snapshots::

    $ git commit -m "My commit message"

  • git status: show the status of the files of the repository

  • git log: show commit log

Presenter Notes

File status

  • Tracked files: files that were in the last snapshots. They can be in 3 different states:
    • unmodified
    • modified
    • staged
  • Untracked files: all the other files

Presenter Notes

File status lifecycle


Pro Git Boot, by Scott Chacon:

Presenter Notes


Exercises 01_configuring_and_committing.rst

Presenter Notes

Deleting and moving files

  • git rm: Removes files from the working tree::

    git rm FILENAME

  • git mv: Move or rename a file or a directory::


Presenter Notes

Canceling operations

  • git reset HEAD: unstages filename::

    $ git reset HEAD filename

  • git checkout: unmodifies an unstaged file

    $ git checkout -- filename1 filename2

Presenter Notes


Exercises 02_deleting_canceling.rst

Presenter Notes


Presenter Notes

Commits are repository snapshots.


Presenter Notes

A branch is a pointer to a commit.


Presenter Notes

So we can have many branches !


Presenter Notes

But how to know in which branch we are ?


Presenter Notes

We can switch branches.


Presenter Notes

And commit in a branch.


Presenter Notes