interactive rebase

Rebasing

What, we're not done?

interactive rebase

A more powerful way of rebasing

We know that when we rebase we are "replaying" commits

What if we could decide step-by-step what to do with each commit?

interactive rebase

Rebasing interactively

git rebase --interactive

git will then open a heavily commentated file that will specify how the rebase will be done

We are not going to see what every command does, just a few

interactive rebase

What can we do with this file?

Citing the last three lines in the file:

These lines can be reordered; they are executed from top to bottom.
If you remove a line here THAT COMMIT WILL BE LOST.
However, if you remove everything the rebase will be aborted.
    
interactive rebase

Interactive rebase: pick and drop

interactive rebase

Interactive rebase: fixup and squash

interactive rebase

Best use for fixup

Rember the question we left suspended a while ago?

What if we do not want to add our changes to the last commit?

fiuxp commits to the rescue

interactive rebase

Fixup commits

commit has the very helpful --fixup <sha> option:

It will create a commit with a standard commit message. During a rebase, we can tell git to auto-merge it for us!

interactive rebase

Autosquash

To tell git to auto-merge fixup commits we need to pass --autosquash to rebase

interactive rebase

Isn't this just like a "i forgor 💀" commit?

Yes, it is.

However,

Fixups are much more maintainable since with a simple option they can be merged into their respective commits

Just don't push them