Collaboration with git

Using git as a first-time contributor

Pascal Burkhard

ROpenSci Community Call

January 20, 2025

About me

  • Msc in Geography and English Linguistics
  • High school teacher in Geography and Computer Science
  • Experience with R: about 15 years
  • Basic use of git: about 10 years
  • First contribution to a FOSS R package, {babelquarto}: 2024

I learned more in the first two months of collaboration
than in the previous ten years of using git on my own.

Why git?

I’m asuming you have some basic knowledge of git. If not, I recommend Jenny Bryan’s Happy Git and GitHub for the useR.

Working with git on your own repository is a good start to get familiar with concepts like add, commit, push and so on.

Collaborating with git will take you on a whole
new journey of discovering the powers of git.

Collaboration with git

Some of my personal takeaways after using git in collaboration with others:

  • Use branches… A LOT !
  • Commit often
  • Write meaningful commit messages
  • Learn how to undo stuff
  • Learn how to rebase
  • Get familiar with GitHub’s Pull Requests

Mistakes happen

Change your last commit:

git commit --amend --no-edit
git commit --amend -m "New commit message"

git undo a commit:

git reset <SHA>
git reset <SHA> --hard

git undo a pushed commit:

git revert <SHA>

Worst case? 🔥 Burn it all down and start over!

Rebase – unleash ninja powers

Rebase is the Swiss Army knife of git. Among other things, you can:

  • Squash (combine) commits
  • Reorder commits
  • Edit past commits
  • Drop past commits

Note

Rebase is also a great way to keep your branch up-to-date with the main branch.

Git GUI

  • Git GUIs can be really helpful

  • My experience with Positron and the Git Graph extension was life-changing!

  • Change your git config to use your preferred editor (and avoid the horror of vim):

    git config --global core.editor  "positron  
      --wait --reuse-window"

Some helpful resources

Thank you!

Thank you for
your attention!