Collaborative coding with GitHub and RStudio

About this work

This work was originally created by Anna Krystalli from RSE-Sheffield under a MIT licence, and was subsequently adapted by Malika Ihle from Reproducible Research Oxford, with the contributions of Adam Kenny. The overview image is from Dumitru Uzun. The exercice is based on the research of Jen Bright who also kindly provided the gifs used in the exercice. You are free to use, copy, modify, distribute this work for your own projects.

This session follows-up from the Introduction to RStudio, Git, and GitHub and is accompanied by this 10 min introductory videorecording.


Overview of the exercice

In this session, you will

  • fork a GitHub repository (i.e. copy a collaborator's repository to your own GitHub account)
  • clone it locally (i.e. copy it to your computer while maintaining a connection to your remote (GitHub) version)
  • create a new file locally and commit it to your local repository (i.e. save the file locally in your version control system)
  • push your changes to your GitHub version (i.e. synchronise your local changes with your remote repository)
  • contribute a file to the original repository by making a pull request (i.e. request your collaborator, the owner of the original repository, to fetch your proposed changes and merge them into the original repository)
  • observe the outcome of all contributions merged by your collaborator
  • pull the upstream repository into your fork (i.e. update your fork to reflect all the changes that happened in your collaborator's original repository)


In this example, the file you will contribute is required to simulate the evolutionary trajectory of an imaginary bird species’ body size. We will use RStudio and GitHub to collate all species files and plot them all up together at the end. We will also discover the skull and beak shapes associated with each species you contributed (after they 'evolved' through a simple brownian motion model which assumes steps to progress completely at random).


Step-by-step tutorial

The material is self-paced and it is necessary that you work through the sections in order.

  • Fork - Copy your collaborator's repository
  • Clone - Copy your repository locally
  • Commit - Make changes and save them locally
  • Push - Update your remote repository with your local changes
  • Pull request - Ask your collaborator to integrate your changes in their repository
  • Merged results - Observe the merge of all contributions
  • Pull the upstream repository into your fork - Update your fork with all contributions made to the original repository