Skip to content

Instantly share code, notes, and snippets.

@vperron
Created May 16, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vperron/5dac6cc3ca12eb11e7241ded33a7f60f to your computer and use it in GitHub Desktop.
Save vperron/5dac6cc3ca12eb11e7241ded33a7f60f to your computer and use it in GitHub Desktop.
#!/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