1 of 13

Github Collaboration

With Brooke and Tim

3 Nov 2022

2 of 13

Why use Github?

  • Free web host
  • Facilitates reproducible research
  • Interact with repositories on multiple platforms, including command line
  • Keeps code-heavy projects organized, especially when there is more than one code author

3 of 13

Emergent Lab Github

4 of 13

Git allows you to do something that you can’t in Google Docs, Microsoft Online etc - work on different versions of the same document independently and then manually merge the changes while saving all the intermediates

5 of 13

Working between local and remote repositories

git clone

6 of 13

First things first: Configure your SSH

7 of 13

Clone: copy of repository that lives remotely from the web server (allows for changes to original repository)

Fork: personal copy of another user’s repository that lives on your account (does not change the original repository)

Branch: parallel version of a repository which can be merged back to the main “live” version

Pull: act of proposing a change to a repository submitted by a user and reviewed by a contributor

Push: Send committed changes to a repository on github.com

8 of 13

Working between local and remote repositories

git clone

9 of 13

Command line Workflow

  1. Create a directory for the repo you wish to work with: mkdir [repo name]
  2. Git clone the repo into your directory: git clone git@github.com:git@github.com:Read-Lab-Confederation/github-collab-practice.git
  3. Create a new branch for your edits: git checkout -b [branch name]
  4. Edit and create files within the repo
  5. Add your changes to the repo: Git add
  6. Commit edits with message: git commit -m “this is my change”
  7. Push edits from the branch to the main branch: git push –set-upstream origin [branch name]

10 of 13

Practicing Github Collaboration

Together, we’re making a piece of “master code” by re-assembling the poem “Jabberwocky”

  1. Clone the Github Repo “github-collab-practice” from the command line
  2. Examine the tasks, and pick 1 task file
  3. Create a new branch for your task
  4. Perform the appropriate Add, commit, and push requests
  5. When everything is complete, We’ll review the pull and merge requests together (Tim will be the merger)

11 of 13

Tasks Cheat Sheet (DRAFT SLIDE)

Task #1: Add the following text to lines 9-12 of the text file “Jabberwoky_exercise.txt” :

“Beware the Jabberwock, my son!

The jaws that bite, the claws that catch!

Beware the Jubjub bird, and shun

The frumious Bandersnatch!”

Task #2: Add the following text to lines 24-27 of the text file “Jabberwoky_exercise.txt”:

One, two! One, two! And through and through

The vorpal blade went snicker-snack!

He left it dead, and with its head

He went galumphing back.

Task #3: Edit in line 4 “slithy toves” to “slimy toads” in the text file “Jabberwoky_exercise.txt”

Task #4: Add a new stanza to the end of the text file “Jabberwoky_exercise.txt” (write it if you want, or just copy something)

Task #5: Create a new file in the repository called “how_doth_the_crocodile.txt” with the poem How Doth the Little Crocodile? (text below): How doth the little crocodile

Improve his shining tail,

And pour the waters of the Nile

On every golden scale!

How cheerfully he seems to grin,

How neatly spreads his claws,

And welcomes little fishes in,

With gently smiling jaws!

Task #6: Add the following text to line 24 of the text file “Jabberwoky_exercise.txt”: “ONE, TWO! ONE, TWO! AND THROUGH AND THROUGH”

Task #7: Capitalize “vorpal sword” in the text file “Jabberwoky_exercise.txt”

Task #8: Add a definition for “gimble” at the end of the text file “Jabberwoky_exercise.txt”

Task #9: Add the names of the lab mates working on the document to the author line of the text file “Jabberwoky_exercise.txt”

Task #10: Rewrite line 17 with a new rhyming word in the text file “Jabberwoky_exercise.txt”

12 of 13

Now let’s review the pull requests together

13 of 13

Let’s Time Travel

What if we wanted to see what an earlier version of our master code looked like?

We can examine specific commits in branches that we made:

Git checkout BRANCHNAME

Creating a new branch from an old commit:

git branch NEW_BRANCH_NAME COMMIT_ID