Last active
August 31, 2015 15:31
-
-
Save virajkanwade/f0fd5002b28ea9581cda to your computer and use it in GitHub Desktop.
git_reset_branch.sh
This file contains 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
# DO NOT MAKE THIS EXECUTABLE | |
# USER COULD LOSE CODE | |
# SHOULD ALWAYS BE MANUALLY RUN AS "bash git_reset_branch.sh" | |
# LICENSE: GPL3 | |
# AUTHOR: Viraj Kanwade | |
# URL: https://github.com/virajkanwade | |
set -e | |
# BRNCH="$(git branch | grep '^\*' | awk '{ print $2 }')" | |
BRNCH="$(git name-rev --name-only HEAD)" | |
echo $BRNCH | |
REMTE="$(git config branch.${BRNCH}.remote)" | |
echo $REMTE | |
if [[ -z "$REMTE" ]] | |
then | |
echo "No remote found for ${BRNCH}" | |
exit 1 | |
fi | |
git fetch && git reset --hard ${REMTE}/${BRNCH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment