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
  • Many ways to work with GitHub

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

Connecting remote and local repositories

  • git clone - if you started the repository on GitHub
  • git init - if you started the repository on your computer

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 changes from the remote repository to 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

Live Demo

Let’s make our first commit!

Activity

  1. Following the template provided here, create a new Markdown document (.md) 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.