Rebasing is named after the practice of taking commits from one point in history and replaying them atop another, allowing related commits to remain grouped together whilst also including changes made outside of its history.


Assume you made a commit containing a typo or a lint error:

$ echo '# Tyopgraphy' >
$ git add
$ git commit -m Boilerplate
[master (root-commit) b72086d] Boilerplate
 1 file changed, 1 insertion(+)
 create mode 100644

Maybe we've done some other work in the middle and it's impractical now to commit --amend, we can instead create a fixup commit:

$ git commit --fixup b72086d
[master ea70229] fixup! Boilerplate
 1 file changed, 1 insertion(+), 1 deletion(-)

Post-review, we can squash this:

git rebase -i --root --autosquash

Which will result in a rebase planned as follows:

pick b72086d Boilerplate
fixup ea70229 fixup! Boilerplate


--autostash will automatically stash save and stash pop before and after rebases, reducing friction.