Last active
June 14, 2018 11:24
-
-
Save astromechza/e8aa09d53a120a918345f7f84d4adbf7 to your computer and use it in GitHub Desktop.
A bash function for git-squash-reset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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