Last active
March 2, 2022 17:11
-
-
Save richstokes/10445918381732739420e0d69cb8c275 to your computer and use it in GitHub Desktop.
git easy rebase script
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 | |
set -e | |
FEATURE_BRANCH=$(git branch --show-current) | |
if [ "$FEATURE_BRANCH" == "main" ]; then | |
echo "Looks like you're not on a feature branch 🌲, so we'll just update main 🔺" | |
git pull | |
exit | |
else | |
echo "Rebasing $FEATURE_BRANCH against main ⚾️" | |
echo "Updating main 🌲" | |
git checkout main | |
git pull | |
git checkout $FEATURE_BRANCH | |
echo "Rebasing ⚾️" | |
#git rebase main #Use this if NOT using "squash and merge" commits in PRs | |
git rebase main --strategy-option ours | |
echo "Force Pushing 👊🏽" | |
git push -f origin $FEATURE_BRANCH | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment