Last active
July 22, 2021 14:03
-
-
Save whunter/cd118aad08f6863ca1b559f5c1ed575e to your computer and use it in GitHub Desktop.
Squash your commits super easily
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
#!/bin/bash | |
# Add a "squash" alias that calls this file and then you can squash your commits by running "squash master" (or whichever branch you want to rebase against) | |
base_branch=$1 | |
if [[ -n "$base_branch" ]]; then | |
current_branch=`git branch --show-current`; | |
echo "Squashing $current_branch"; | |
commits=`git log $base_branch..$current_branch --oneline | wc -l | xargs`; | |
echo "$commits commits"; | |
git rebase --interactive HEAD~"$commits"; | |
else | |
echo "Usage: squash <base_branch>"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment