Skip to content

Instantly share code, notes, and snippets.

@richstokes
Last active March 2, 2022 17:11
Show Gist options
  • Save richstokes/10445918381732739420e0d69cb8c275 to your computer and use it in GitHub Desktop.
Save richstokes/10445918381732739420e0d69cb8c275 to your computer and use it in GitHub Desktop.
git easy rebase script
#!/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