Last active
September 9, 2019 14:54
-
-
Save clairesrc/3117870988338bdf071a40e556858b25 to your computer and use it in GitHub Desktop.
Trunk Rebase Utility
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/bash | |
BASEBRANCH=${1:-master} | |
HEADBRANCH=`git rev-parse --abbrev-ref HEAD` | |
if [ "$BASEBRANCH" == "--help" ] || [ "$BASEBRANCH" == "-h" ]; | |
then | |
echo "Usage: rebase BASEBRANCH (defaults to master)" | |
echo "Re-run the same command after fixing conflicts to reset upstream branch and push." | |
exit | |
fi | |
echo Rebasing $HEADBRANCH from $BASEBRANCH | |
git fetch --all | |
git branch --set-upstream-to origin/$BASEBRANCH | |
git pull --rebase && git branch --set-upstream-to origin/$HEADBRANCH && git push origin HEAD -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment