Skip to content

Instantly share code, notes, and snippets.

@virajkanwade
Last active August 31, 2015 15:31
Show Gist options
  • Save virajkanwade/f0fd5002b28ea9581cda to your computer and use it in GitHub Desktop.
Save virajkanwade/f0fd5002b28ea9581cda to your computer and use it in GitHub Desktop.
git_reset_branch.sh
# 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