This lesson is being piloted (Beta version)

Introduction to git

Key Points

Motivation
  • Version control is like an unlimited ‘undo’.

  • Version control also allows many people to work in parallel.

In-browser session
  • Bitbucket is a service that uses git and provides 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 often 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
  • 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.