Skip to content

Instantly share code, notes, and snippets.

@waffle2k
Created August 7, 2013 15:52
Show Gist options
  • Save waffle2k/6175374 to your computer and use it in GitHub Desktop.
Save waffle2k/6175374 to your computer and use it in GitHub Desktop.
For some reason, I can never remember the rebase command, yet I use it all of the time. This is handy if you're done with your commits, and you're ready to merge back into master. First, rebase all of your commits with "f" to fixup all of them before merging. This follows the convention of "1 change, 1 commit".
#!/bin/bash
#
# This is just a wrapper for : git rebase -i HEAD~4
BACK=$1
function die {
echo "$1"
exit 1
}
if [ -z $1 ]; then
die 'You must specify an integer, representing the number of commits to squash'
fi
echo $BACK | egrep -q -e '^[0-9]+$' || die 'Supplied arg is not an integer value'
git rebase -i HEAD~${BACK}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment