Created
September 9, 2017 15:59
-
-
Save mgamer/3b8f7b0ff782140c480ecd69ef366ab0 to your computer and use it in GitHub Desktop.
git squash
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
#!/bin/sh | |
# based on https://stackoverflow.com/a/24018435/59666 | |
#base commit of the squash-"rebase | |
baseCommit=$1 | |
#get the commit message | |
shift | |
commitMsg=$@ | |
#regular expression to verify that squash number is an integer | |
regex='^[0-9]+$' | |
echo "---------------------------------" | |
echo "Will squash using $baseCommit as base" | |
echo "Commit message will be '$commitMsg'" | |
echo "...validating input" | |
if [ -z "$commitMsg" ] | |
then | |
echo "Invalid commit message. Make sure string is not empty" | |
else | |
echo "...input looks good" | |
echo "...proceeding to squash" | |
git reset --soft $baseCommit | |
git commit -m "$commitMsg" | |
echo "...done" | |
fi | |
echo | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment