HomeToolsAbout

Rebasing

Rule of Thumb

Always branch off before doing large rebase

This allows you to hard reset to the original branch when a rebase goes wrong.

Incrementally squash/rebase instead of doing it all at once

Isolate the commits that are troublesome while rebasing.

Rebasing

git rebase -i HEAD~n

Abort

Manually trigger Vim error to abandon rebasing from completing

:cq

Resolving Conflicts

git add <file> git rebase --continue

Squashing using Interactive Rebase

Below example will fold 4 commits into the first commit:

pick a1b2c3d Commit message 1 squash d4e5f6g Commit message 2 squash h7i8j9k Commit message 3 squash l0m1n2o Commit message 4

Cleaning up commit

Always prefer squash over deletion of commit

  • IF you accidentally chose HEAD position that includes commit you don't want to squash
    • Simply remove the commit from the list
AboutContact