Hack your way to a good git history
Maëlle Salmon
Less loss of work ;
Experiments in branches ;
History to use (locally and on platforms like GitHub).
Julia Evans’ zines “Oh shit, Git!” and “How Git works”
Book Git in Practice by Mike McQuaid (reading notes)
Book Pro Git by Scott Chacon (reading notes)
Small commits with informative messages
“Commit a bunch of files before lunch 🍝”
Showing 145 changed files with 2,624 additions and 2,209 deletions.
“fix: adapt code to tool’s 0-indexing”
Showing 2 changed files with 3 additions and 2 deletions.
Oh no, that idea from 7 commits ago is bad! Do we…
Manually remove the change;
Revert the commit that added the change?
It only works well if the commit is small.
“Commit a bunch of files before workout 💪”
Showing 145 changed files with 2,624 additions and 2,209 deletions.
“refactor: start using YAML”
Showing 2 changed files with 3 additions and 2 deletions.
Your repository’s Git history should be like your Instagram profile grid.
“there’s no need for everyone to see the mistakes you made along the way”
Mike McQuaid, Git in Practice
Another dimension to your work.
Work in branches
git commit --amend
What is git commit --amend
git commit --amend
https://happygitwithr.com/repeated-amend
First bit of work, git commit -m "feat: add cool thing"
Second bit of work, git commit --amend --no-edit
…
Done! git push
git commit --amend
git checkout -b 'feature-thing'
First bit of work, git commit -m "feat: add cool thing"
, git push
Second bit of work, git commit --amend --no-edit
, git push -f
…
Done! git push -f
git reset --mixed
Changes in the directory but not the Git history.
git add (--patch)
Build commits in hindsight.
git rebase -i
Better history in particular for
git blame
git bisect
git revert
✨ No need to get it right on the first try ✨
The Repeated Amend ™️
Squash and Merge PRs
Start from Scratch
Mix and Match your Commits
Practice safely in {saperlipopette}’s playgrounds!
Use the tools you prefer!
The terminal: never changes, and you learn the words.
RStudio IDE
Positron IDE, GitLens extension
Other IDEs
GitHub Desktop