You already keep a record of every experiment you run. Git is that record for the analysis: what you changed, when, why — and a way back to any of it.
analysis.py analysis_v2.py analysis_v2_fixed.py analysis_FINAL.py analysis_FINAL_really.py
Every one of these is a commit you made by hand, with no date, no message and no way to see what changed between them. Git does the same job properly, and the folder stays clean: one analysis.py, with its whole history behind it.
Two commands. The first you run once per project; the second you run constantly, and it tells you everything about the state you are in.
cd lab07 git init git status
Git will also ask who you are, once per machine:
git config --global user.name "Your Name" git config --global user.email "you@sussex.ac.uk"
This is the whole of git, for now. Edit something, decide it is worth keeping, write down why. Repeat several times an hour.
# ... you edit 01_find_the_suspects.ipynb ... git status # what changed? git add 01_find_the_suspects.ipynb git commit -m "add the skin-minus-rest difference" git status # clean again
Commit when something works, not when you stop for lunch. Each commit should be one idea, so that going back to it gives you something that runs.
A record you cannot read is not worth keeping. These four commands are how you answer “what did I do, and when did it break?”
9c1d4e2 use blue light, not UV 3b77a10 drop the 2018 surveys 7a3f21c add skin-minus-rest 0e5c8d9 first commit
The short code is the commit's name. You use it to look at a commit, and to go back to one.
Everything so far is bookkeeping. This is the payoff: the afternoon you break something badly and get it back in one command.
# one file, back to the last commit git restore analysis.py # everything, back to the last commit git restore . # just look at an old version first git show 7a3f21c:analysis.py
Try it now: break a notebook on purpose, save it, then bring it back.
This is the real argument for committing often. A commit every twenty minutes means you can never lose more than twenty minutes.
A repository is for the things you wrote. Not for what your computer generated, and not for the raw data — which matters immediately, because the DepMap files are large.
.venv/ __pycache__/ .ipynb_checkpoints/ .DS_Store # data: big, and not ours to redistribute data/*.csv !data/depmap_lecture.csv
The last line is an exception: ignore every CSV except the small teaching file, so everyone who clones the repo can still run the notebooks.
Everything so far lives on your laptop. One more step puts a copy somewhere that survives a spilled coffee — and gives you something to show.
gh auth login # once per machine # make an empty repo on github.com, then: git remote add origin https://github.com/you/lab07.git git branch -M main git push -u origin main
git add . git commit -m "what I changed and why" git push
Make the repo private if you prefer. You can make it public later; going the other way is harder.
You will hear about branching and merging, and one day you will need them. Working alone on one machine, they solve a problem you do not have yet — so here is what they are for, and where to learn them properly.