The secrets
of the Git
ninjas
@cburgdorf
Software Gardener
at CouchCommerce
Every commit is a full snapshot.
no Deltas for fuck's sake
Let's Talk About Branches
A branch is just a name for a specific commit
well almost
Committed on the wrong branch?
git branch featureBranch
git reset --hard HEAD~1
What the Head?!
"The HEAD is just a pointer to where your working directory should currently be on" --cburgdorf
git makes it hard to lose work
As long as you ever had it COMMITTED
Commit early, commit often
the reflog
"The reflog is a history of all movements of the HEAD" --cburgdorf
Pitfalls?
commits that are not reachable by any branch/tag will be GC'ed after 30 days
Commit early, Commit often
yet, nobody wants to read this
We want this
your coworkers will thank you!
""I'll fix that later""
as a workflow
4 commands: wip, ap, add -p, rebase -i
Cherry picking
git cherry-pick
sha4711
git cherry-pick
first~
..
last
Avoid unnecessary Merge commits
merging blindly means
- your history becomes a mess
- YOU hide information in merge commits
- harder to do git bisect
- HARDER TO DO cherry picking
make the console your friend
git config --global alias.ca '!git add -A && git commit'
git config --global alias.lg '!git log --pretty=one-line --abbrev-commit --graph --decorate'
git config --global alias.wip '!git add -A && git commit -m "WIP"'
git config --global alias.ap '!git add -A && git commit --amend --no-edit'
One more thing
Thanks.
@cburgdorf
github.com/cburgdorf
slide.es/cburgdorf/the-secrets-of-the-git-ninjas