Skip to content

Instantly share code, notes, and snippets.

@astromechza
Last active June 14, 2018 11:24
Show Gist options
  • Save astromechza/e8aa09d53a120a918345f7f84d4adbf7 to your computer and use it in GitHub Desktop.
Save astromechza/e8aa09d53a120a918345f7f84d4adbf7 to your computer and use it in GitHub Desktop.
A bash function for git-squash-reset
# A bash function for doing a git squash against a previous commit.
# It includes the dates and messages of the squashed commits and drops you into an editor if you
# need to modify the message further.
git-squash-reset() {
m=$(git log --pretty=format:'- %ad - %s' --date=short "$1...HEAD" --reverse)
l=$(echo "$m" | wc -l | tr -d ' ')
git reset "$1" --soft
git commit -m "Squash of $l commits" -m "$m"
git commit --amend
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment