Skip to content

Instantly share code, notes, and snippets.

@Gaafar
Last active April 1, 2019 12:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gaafar/55b1b7b8da3f7b4905034bd5e6df3abc to your computer and use it in GitHub Desktop.
Save Gaafar/55b1b7b8da3f7b4905034bd5e6df3abc to your computer and use it in GitHub Desktop.
shove to branch
#!/bin/bash
# install:
# copy this file to /usr/local/bin/shove
# sudo chmod +x /usr/local/bin/shove
# then use: shove alpha
remoteBranch=${1?Please specify origin branch to shove}
localBranch=`git symbolic-ref --short -q HEAD`
read -p "Force push local branch ($localBranch) => (origin/$remoteBranch). Proceed? (y/n) " -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
git branch -D $remoteBranch
git checkout -b $remoteBranch
git push -f origin $remoteBranch
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment