git
http://www.phdcomics.com/comics/archive.php?comicid=1323
https://phdcomics.com/comics/archive/phd101212s.gif
One file, lots of versions
git
git
Simplest workflow: just you working on your project, on only one computer.
qmd
manuscript, etc.)Illustrations from the Openscapes blog GitHub for supporting, contributing, and failing safely by Allison Horst and Julia Lowndes
git
workflowgit
workflowUsing a Git commit is like using anchors and other protection when climbing. If you’re crossing a dangerous rock face you want to make sure you’ve used protection to catch you if you fall.
Commits play a similar role: if you make a mistake, you can’t fall past the previous commit. Coding without commits is like free-climbing: you can travel much faster in the short-term, but in the long-term the chances of catastrophic failure are high!
Like rock climbing protection, you want to be judicious in your use of commits. Committing too frequently will slow your progress; use more commits when you’re in uncertain or dangerous territory. Commits are also helpful to others, because they show your journey, not just the destination.
— Hadley Wickham, quoted in Happy git with R
Commits should be ‘atomic’, meaning that they should do one simple thing and they should do it completely. For example, an ‘atomic’ commit could be adding a new function or renaming a variable. If a lot of different changes to your project are all committed together, it can be hard to troubleshoot if any error appears in that version. Furthermore, undoing the whole commit may throw away valid and useful work.
Should help you make sense of the change, even months into the future.
If you are working on a highly collaborative project, important to have a discussion about commit message conventions.
https://www.theodinproject.com/lessons/foundations-commit-messages
You working on a project with a collaborator.
Create a blank repository on gitlab (or github)
Clone it to both machines
Recall the previous workflow: Work, commit, push
We now add an extra step at the beginning: Pull, work, commit, push
You working on a project with a collaborator.
You are testing out some new features of a project - the work may or may not end in success!
(Practical example: you have a working draft of the paper but your advisor suggests an different way to structure the discussion. You want to explore what it would look like if you were to adopt this suggestion.)
The Turing Way project illustration by Scriberia. Zenodo.
Using git
from the command line (bash shell)
pull
, add
, commit
, push
pipelinebranch
diff
sThere are tons of resources for learning git.
Read a few and see which style(s) suit you best.
A handy “cheatsheet” for when something breaks: https://dangitgit.com/
git
tutorial: https://swcarpentry.github.io/git-novice/01-basics.html