Created
February 17, 2015 09:49
-
-
Save xcambar/3f520db33c45e567fdd9 to your computer and use it in GitHub Desktop.
A Shell script to make git squashing a bit more straightforward
This file contains hidden or 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
# gqs <-> git quick squash | |
# | |
# Rebases from the branch passed in argument | |
# Squashes the commits on top of it | |
# | |
# example: gqs origin/master | |
# | |
function gqs () { | |
local branch=$1 | |
git fetch > /dev/null | |
git rebase $branch > /dev/null | |
local number_of_commits=`git log $branch..HEAD --pretty=oneline | wc -l | xargs` | |
if [ $number_of_commits -gt 0 ]; then | |
echo "squashing $number_of_commits commits" | |
git rebase -i HEAD~$number_of_commits | |
else | |
echo "Nothing to squash" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment