Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

chmod +x this file and save it as git-squash in /usr/local/bin, then use git squash while in a feature branch. This saves you the trouble of figuring out the correct references for the rebase which I find tedious. Note that this will automatically pick the tip of master as the reference for the rebase, so make sure that's where you want it to be.

During the rebase I generally mark the first commit as reword and the rest as fixup and give that first commit the log I want the feature to have. If I need to add any further commits, e.g. fixups that are raised during code review, I add those with git commit --fixup <ref>. Then on the next git squash, those will be automatically marked as fixups.

#!/bin/sh
git rebase --interactive --autosquash \
$(git merge-base $(git symbolic-ref --short HEAD) master)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment