GitHub for Collaborative Workflows

Megumi Oshima & Nicholas Ducharme-Barth

January 2025

Version Control

The Turing Way Community. This illustration is created by Scriberia with The Turing Way community, used under a CC-BY 4.0 licence. DOI: 10.5281/zenodo.3332807

Git and GitHub

installed on local computer

tracks changes to files

separate versions

central, remote storage of files

everyone can contribute changes

changes can be combined and shared

We can leverage the interplay between both to help us share code and collaborate with others!

Basic Git/Github Workflow

Commit changesSync remoteand local repositoriesRemote repository onGitHubLocal repositoryCreate new files andmake changes locally

Remote repository on Github

  • Where all of your code and related files lives online
  • Central location where everyone is sharing their changes
  • Connect the remote repository to the files on your local computer
  • git clone
  • git init

Local repository

  • Files kept on your local computer
  • Includes branches from the remote repository
    • allows for different versions of the same file
  • Different from local working directory

Making changes locally

Save

Stage

Commit

Push

Commits

  • groups of small, meaningful changes
  • snapshots of your repository at that time
  • tell a story of the history of your repository

Commits

Make a commit in 2 stages:

  1. save your changes locally and then stage the files you want to commit

    git add <FILENAME>

  1. commit your changes

    git commit -m "descriptive commit message"

Push

To sync the changes you’ve made locally with the remote repository, you need to “PUSH” your commits

git push

Pull

To sync any changes that were made to the remote repository onto your local computer you need to “PULL” commits

2 ways:
1. git pull

  1. git fetch, then eventually git merge

Branches

The default for all repositories is main

mainAdd initial filesCode for model developmentFinalize modelCreate Shiny appAdd reportFinish

mainbuild_modelgrowth_curveAdd initial filesDevelop base modelFinalize base modelChange growth curveCheck new growth curveFinal model report

Pull Requests

Once you have finished development on your branch and want to add your changes to the main branch, you can submit a pull request

Live Demo

Let’s make our first commit!

Activity 1

  1. Following the template provided here, create a new Markdown document with:
  • A list of everyone in your group, including:

    • their affiliation

    • their GitHub name

  • a picture of a species you work on

  • a code chunk with your most used function

  • a task list of three things you would like to learn from the workshop

  1. Save the file with a new name.

  2. Commit your file, and push to the repository.

Activity 2: Branches

  1. Create a new branch from the main branch

  2. Add your name to the list of participants.

  3. Save your change, commit, and push to your branch.

  4. Submit a Pull Request to merge your changes into main branch.