Skip to content

Instantly share code, notes, and snippets.

@mschartman
Created December 5, 2014 18:06
Show Gist options
  • Save mschartman/2cfd0b7bec5f4c0e3f17 to your computer and use it in GitHub Desktop.
Save mschartman/2cfd0b7bec5f4c0e3f17 to your computer and use it in GitHub Desktop.
Git Squash
function squash {
commits_to_squash="1"
commit_message="`git log -1 --pretty=%B`"
if [[ -n "$1" ]]
then
commits_to_squash=$1
fi
if [[ -n "$2" ]]
then
commit_message=$2
fi
git reset HEAD~$commits_to_squash
git add -A &&
git commit -m "$commit_message"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment