June 16, 2026
Git is a distributed version control system.
\[ git \ne GitHub \]
CLI tool, but various GUIs exist1







The hope is that it can encourage and facilitate reproducible science, and just make your life easier, by, among other things:
renv, conda/virtualenv environments or containers).Git is best utilised for plain-text files of any kind.
.bashrc)Avoid git for binary files (Office documents, images, etc.)1 or large files2.
Source: XKCD
Source: Allison Horst
Source: https://reproducibility.rocks/materials/day2/02-git/
add -> commit -> push workflow first is crucialTip
Read git’s warning and help messages carefully. Once you understand the basic syntax, they can often be very useful to (re)solve basic tasks.
My own creations:
General guides:
A highly recommended guide for the perplexed (advanced beginners): http://think-like-a-git.net/
Git from the Bottom Up: https://jwiegley.github.io/git-from-the-bottom-up/
Git from the inside out: https://maryrosecook.com/blog/post/git-from-the-inside-out
Visualizing Git’s Merkle DAG with D3.js: https://tylercipriani.com/blog/2016/03/21/Visualizing-Git-Merkle-DAG-with-D3.js/
Git for Computer Scientists: http://eagain.net/articles/git-for-computer-scientists/
Git is a Directed Acyclic Graph and What the Heck Does That Mean?: https://medium.com/girl-writes-code/git-is-a-directed-acyclic-graph-and-what-the-heck-does-that-mean-b6c8dec65059
Hosting services like GitHub, Bitbucket, and GitLab.
All very similar. Slight differences in naming conventions (e.g. pull vs merge requests). Offer different higher-level features like issues, pull requests, wikis, project boards, etc.
Source: https://reproducibility.rocks/materials/day2/02-git/
Setup SSH-based authentication so that you can clone/push/pull via the SSH protocol instead of HTTPS (otherwise you have to constantly provide your username).
git@github.com:pmoris/my-repo.git
vs
https://github.com/pmoris/my-repo.git
Remote repositories can (usually) be made public or private.
You can even keep a git repo local only. So there really is no excuse not to use git from a security/privacy standpoint.
Avoid storing git repositories on OneDrive
List files you do not want to track in .gitignore.
Useful for sensitive data, secrets, temporary files/caches, etc.
https://pmoris.github.io/git-workshop/chapters/5-branching.html
--force

git stash
Makes it easier to chunk changes into sensible commits. Cleaner history + easier to selectively undo/apply changes.
Very easy to do with a dedicated GUI or directly within RStudio/VScode.
Alternative, use git add -i: https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging
git fetch will check the remote and tell you about updates.
git pull will pull them in by running git fetch followed by git merge.



main and master. Check with git branch -a.HEAD: A named reference to the commit at the tip of a branch. See https://jvns.ca/blog/2024/03/08/how-head-works-in-git.origin. Check with git remote -v.
Tip
For more advanced terminology, like HEAD~, fast-forwarding, reset vs revert, checkout and detached HEAD, see:
