Last active
October 28, 2020 13:03
-
-
Save byF/801c2d56f3fb4306d8d154da6d83044f to your computer and use it in GitHub Desktop.
Put the git-force-pull script on your PATH and voi-la, you can use git force-pull command
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/sh | |
. "$(git --exec-path)/git-sh-setup" | |
USAGE="BRANCH" | |
_force_pull() { | |
if [ $# = 1 ]; then | |
git ls-remote -q --exit-code --heads origin $1 2>&1 1>/dev/null | |
if [ $? = 0 ]; then | |
git fetch origin $1 | |
git reset --hard origin/$1 | |
else | |
die "Branch \`$1\` does not exist" | |
fi | |
else | |
usage | |
fi | |
} | |
_force_pull $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment