Skip to content

Instantly share code, notes, and snippets.

@brianloveswords
Last active August 29, 2015 14:20
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save brianloveswords/44760605a70d84d99eeb to your computer and use it in GitHub Desktop.
Save brianloveswords/44760605a70d84d99eeb to your computer and use it in GitHub Desktop.

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