Combine commits with Rebase – squashed!

If you commit often while deep inside a coding tornado, that’s great, but you should clean up after the whirlwind so that your commits tell a better story.

Use an interactive rebase to combine multiple smaller incremental commits into larger ones. This helps swab out the dumb “forgot something” or “code cleanup” commits, and enables you to summarize a day’s work into one, or more, concise commits.

git rebase -i HEAD~4

The ~4 in the command designates the number of previous commits that you wish to combine.

The command will open up a text editor from wich you can choose which commits to ‘pick’ and which to ‘squash’. After you save and close, you should be prompted to edit the final commit message, which will contain all of the individual commit messages from the combined commits. Save and close that and you’re done. Squashed like beef. Like the Chris Brown/Drake beef.

Snippets and tagged