Skip to content

Instantly share code, notes, and snippets.

@yoichi
Created November 4, 2015 21:21
Show Gist options
  • Save yoichi/a9626fc4ccc2446c6f14 to your computer and use it in GitHub Desktop.
Save yoichi/a9626fc4ccc2446c6f14 to your computer and use it in GitHub Desktop.
#!/bin/bash
BRANCH=$(git rev-parse --abbrev-ref HEAD)
REMOTE=$(git config --get branch.${BRANCH}.remote)
if [ -z ${REMOTE} ]; then
echo "no remote"
exit -1
fi
git fetch
if [ $? != 0 ]; then
echo "fetch failed"
exit -1
fi
git reset --hard ${REMOTE}/${BRANCH}
if [ $? != 0 ]; then
echo "reset failed"
exit -1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment