Repository navigation
Rebase and Clean History
bparlaker edited this page Oct 6, 2026
·
2 revisions
Both integrate changes from one branch into another:
merge rebase
A---B---E---M (main) A---B---E (main)
\ / \
C---D (feature) C'---D' (feature)
- merge keeps the true history, adds a merge commit.
-
rebase replays your commits on top of the new base → a straight line. The commits get new hashes (
C',D').
git switch feature
git rebase main # replay feature on top of latest main
# on conflict: fix files, git add, git rebase --continue (or --abort)git rebase -i HEAD~4Git opens an editor:
pick a41c7e2 docs: add labels page
pick 9d2b113 typo
pick 3b9f0d1 docs: explain colours
pick 0cc8a17 wip
Change the verbs:
pick a41c7e2 docs: add labels page
fixup 9d2b113 typo # melt into previous, drop message
reword 3b9f0d1 docs: explain colours
drop 0cc8a17 wip
Result: 2 clean, meaningful commits instead of 4 noisy ones.
git switch main
git cherry-pick 3b9f0d1 # apply just that commit heregit bisect start
git bisect bad # current version is broken
git bisect good v1.0 # this tag was fine
# Git checks out a midpoint; test it, then:
git bisect good # or: git bisect bad
# ...repeat ~log2(n) times...
git bisect resetWith 1,000 commits between good and bad, bisect finds the culprit in about 10 steps. It can even run automatically: git bisect run ./test.sh.
git config --global alias.lg "log --oneline --graph --decorate --all"
git config --global alias.st "status -sb"
git config --global alias.undo "reset --soft HEAD~1"🎨 Term Project
📘 Git
🗂 Project workflow