Organize your research and teaching material with Git

Day 3/4: Creating and maintaining your GitHub repository

Waldir Leôncio Netto

Research Software Engineer
Oslo Centre for Biostatistics and Epidemiology (OCBE)

https://github.com/ocbe-uio
https://github.com/wleoncio

Course plan (subject to change)

Day
Date
Focus
1
02 Nov
10:00-11:30
Git basics+ (status, add, commit, log, diff, reset, branch)
For all users, no matter how or where they work
2
09 Nov
10:00-11:30
Git + GitHub on RStudio (Stata/others get limited support)
Changing Git history (amend, squash, fixup)
3 16 Nov
10:00-11:30
Create and maintain a GitHub repository
(fetch, pull, push, issues, merge, rebase)
4 23 Nov
10:00-11:30
Collaborating on GitHub
(pull requests, merge conflicts, blame, fork)

Class rules (day 3)

Course slides

🌐 Available on https://ocbe-uio.github.io/public-slides/
📜 Licensed under Creative Commons Attribution-ShareAlike

Workflow

⁉️ At any time (in-person or chat)
💻 Requirements: Git; GitHub account with SSH keys

Day 1, 2 recap

Creating a GitHub repository

  1. Website
  2. Command line (GitHub CLI, https://cli.github.com/)

Connecting your remote and local repositories

Maintaining a GitHub repository

Feature Navigate Document Produce
Wikis ✔️
Discussions ✔️
Projects ✔️
Issues ✔️ ✔️
Pull requests ✔️
Codespaces/Code browser ✔️ ✔️

Basic elements

Think of your future self and potential collaborators!

  • License
  • README.md
  • "good first issue" label
  • Insights > Community Standards

Issues vs. Pull Requests (PR)

Task Issue Pull Request
1 Open Work on
2 Triage Open
3 Work on Triage
4 Close Merge or close
  • "Issues" are not just for issues!
  • PRs (better known as "Merge requests" on GitLab) will be covered on day 4
    • More important for joint projects ("peer-review process") than solo

Opening issues

  1. Website
  2. GitHub CLI

Working on issues

  1. Create new branch
  2. Work on issue
  • Try not to work on other things (see discussion on rebase next)
  • Add issue number to commit messages (that's your only link back)
  1. Merge back into main
  2. Close issue

Fixing different things simultaneously

Merge vs. rebase

  • Updating a local (offline) branch? git rebase $incoming_branch
  • Is the branch already on GitHub? git merge $incoming_branch