28 Git

28.1 What’s git?

Git is a free and opensource version control system

  • commonly used through a server
    • where a master copy of a project is kept
    • can also be used locally
  • allows storing versions of a project
    • syncronisation
    • consistency
    • history
    • multiple branches

28.2 How git works

A series of snapshots

  • each commit is a snapshot of all files
  • if no change to a file, link to previous commit
  • all history stored locally


by Scott Chacon and Ben Straub, licensed under CC BY-NC-SA 3.0

28.3 Three stages

When working with a git repository

  • first checkout the latest version
  • select the edits to stage
  • commit what has been staged in a permanent snapshot


by Scott Chacon and Ben Straub, licensed under CC BY-NC-SA 3.0

28.4 Basic git commands

  • git clone
    • copy a repository from a server
  • git fetch
    • get the latest version from a branch
  • git pull
    • incorporate changes from a remote repository
  • git add
    • stage new files
  • git commit
    • create a commit
  • git push
    • upload commits to a remote repository

28.5 Git and RStudio

RStudio includes a git plug-in

  • clone R projects from repositories
  • stage and commit changes
  • push and pull changes