Skip to content

Instantly share code, notes, and snippets.

@byF
Last active October 28, 2020 13:03
Show Gist options
  • Save byF/801c2d56f3fb4306d8d154da6d83044f to your computer and use it in GitHub Desktop.
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
#!/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