Created
May 16, 2017 16:20
-
-
Save vperron/5dac6cc3ca12eb11e7241ded33a7f60f to your computer and use it in GitHub Desktop.
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 this to your bashrc to get 'git branch'-like completion: | |
# | |
# _git_polypush() | |
# { | |
# _git_branch | |
# } | |
set -xe # fail on first error | |
BRANCH=$1 | |
# Get current branch name | |
# BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [ "X${BRANCH}" == "Xmaster" ]; then | |
echo "Rebase master on master then push on origin master is not a good idea..." | |
fi | |
echo "> synchronizing master..." | |
git fetch origin | |
git checkout master | |
git rebase origin/master master | |
echo "> interactive rebase of ${BRANCH} onto latest master..." | |
git checkout $BRANCH | |
git rebase master -i | |
echo "> fast-forward local master to the top of ${BRANCH}" | |
git checkout master | |
git rebase $BRANCH | |
echo "> force-push branch to github and update remote master..." | |
git push origin $BRANCH:$BRANCH -f | |
git push origin master:master | |
echo "> deleting local & remote ${BRANCH}..." | |
git push origin :${BRANCH} | |
git branch -D $BRANCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment