DEV Community

Cover image for Pick. Squash. Drop. Rebase! (Comic)

Pick. Squash. Drop. Rebase! (Comic)

Erika Heidi on January 24, 2020

Git Rebase allows us to rewrite Git history. It is a common practice to use git rebase to squash commits before creating or merging a pull request;...
Collapse
 
aptituz profile image
Patrick Schönfeld • Edited

One of the most useful things I learned for my workflow is git commit —fixup - because often enough I know in advance what is just a correction of a previous commit. I can then automatically cleanup history with git rebase —autosquash.

Collapse
 
jln profile image
JLN

Why not just ammend it to the previous commit?

Collapse
 
aptituz profile image
Patrick Schönfeld

Because fixup also works for other commits in the history. Like when I am working on a branch with multiple commits that represent different logical changes and I find an issue with it. Then I can fixup the commit it belongs to and retain a clean history.

Thread Thread
 
aptituz profile image
Patrick Schönfeld

(Of course I am talking about multiple commits that have not yet been merged anywhere else)

Collapse
 
nikoheikkila profile image
Niko Heikkilä

I can recommend rebasing when working in a team. Keeps the history so much cleaner!

Additionally, in my team, we use a lot of fixup (squash the commit but keep the message) and reword (change the commit message but keep the content) when doing interactive rebasing. Both are very valuable prior to push or merge.

Collapse
 
jwp profile image
John Peters

What's the difference between rebase and merge with master?

Collapse
 
nikoheikkila profile image
Niko Heikkilä

Atlassian has this covered better than I could put in words. Read on!

Collapse
 
sgharms profile image
Steven G. Harms

Great example case, cards in a deck. There are some card games that have that play dynamic (flavors of gin rummy, as we call it here in the US) let you take a card in the "stack" but you have to take all the cards on top of it.

Collapse
 
richardeschloss profile image
Richard Schloss • Edited

Cool! You did this! I didn't think anyone would pay attention to my comment last time :) (and I'm glad you support squashing commits!)

Collapse
 
realtoughcandy profile image
RealToughCandy.io

Rad!

Collapse
 
bmitchinson profile image
Ben Mitchinson

Amazing!

Collapse
 
lilislilit profile image
Crusten

Amazing! Thank you!

Collapse
 
jwp profile image
John Peters

Thanks for post Ericka.

Collapse
 
raulismasiukas profile image
Raulis Masiukas

Great contribution, thanks!

Collapse
 
kathryngrayson profile image
Kathryn Grayson Nanz

super cute comic!! and good info

Collapse
 
erikaheidi profile image
Erika Heidi

Thank you! 🤗