Motivation


  • Version control is like an unlimited ‘undo’.
  • Version control also allows many people to work in parallel.

In-browser sessionIn-browser session


  • There are multiple online repositories for storing projects that all use the underlying Git framework
  • Bitbucket is one such service, using Git to provide functionality to collaborate with other people
  • We can browse the history of the contents of repositories and see who made which changes
  • Other platforms like Github look different by employ the same fundamentals

Configuring Git


  • git configuration is all stored in ~/.gitconfig
  • The config is specific to each computer you use.

Our first repo


  • Initializing a Git repository is simple: git init
  • Commits should be used to tell a story.
  • Git uses the .git folder to store the snapshots.

Undoing things


  • Git history can be reverted without modifying it
  • Once changes are committed they are safe
  • Changes that are not committed can be deleted

Branching and merging


  • A branch is a division unit of work, to be merged with other units of work.
  • A tag is a pointer to a moment in the history of a project.

Conflict resolution


  • Conflicts usually appear because of not enough communication or not optimal branching strategy.

Sharing repositories online


  • A repository can have one or multiple remotes
  • A remote serves as a full backup of your work.
  • git push sends local changes to the remote
  • git pull gets remote changes onto your local machine.
  • A remote allows other people to collaborate with you

Collaborating with git repositories


  • Sharing a repository needs good communication.
  • Branches are really necessary.
  • Pull requests enable sensible merging of changes between branches and across repositories.

Making git citable


  • Git tags may be generated to note a particular version in history.
  • Consider use of git early in scientific workflows, for robust documentation.
  • Open scientific work is more useful and more highly cited than closed.

What to not add to Git


  • Make use of .gitignore to list files to exclude.
  • Don’t commit sensitive, personal or machine-specific information.
  • Don’t commit large data files.
  • Git works best with text files, for which it can track individual line changes.