Skip to content

Instantly share code, notes, and snippets.

@meoso
Last active April 26, 2017 18:09
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 meoso/a52cf920fcac1b9ee2ca to your computer and use it in GitHub Desktop.
Save meoso/a52cf920fcac1b9ee2ca to your computer and use it in GitHub Desktop.
git fetch all & reset head
#!/bin/bash
#######################################################
# purpose : git fetch all & reset head i.e. git force pull
# author : njd
# created : 2017-04-26
# usage : ./git-force-pull.sh [path]
#######################################################
if ! [[ -z "$1" ]] ; then
cd "$1" || exit 1
fi
FS=$(pwd)
read -r -p "Force git pull losing all local edits ($FS)? [y/N] " response
case "$response" in
y) #git reset
git fetch --all
git reset --hard origin/master
git pull origin master
;;
*) echo "aborted"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment