Last active
April 26, 2017 18:09
-
-
Save meoso/a52cf920fcac1b9ee2ca to your computer and use it in GitHub Desktop.
git fetch all & reset head
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/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