Skip to content

Instantly share code, notes, and snippets.

@t3hnar
Last active October 31, 2019 15:36
Show Gist options
  • Save t3hnar/377684153edb6aa6bacbbff1a23abefc to your computer and use it in GitHub Desktop.
Save t3hnar/377684153edb6aa6bacbbff1a23abefc to your computer and use it in GitHub Desktop.
revert-to.sh
REVISION=$1 &&
BRANCH=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') &&
git reset --hard $REVISION &&
MSG="revert $BRANCH to ${REVISION}" &&
git merge -s ours @{1} -m "${MSG}" &&
echo $MSG
@t3hnar
Copy link
Author

t3hnar commented Oct 31, 2019

Usage example:

revert-to.sh d595a7a95bf8816fcda32ea7dce3f1476874580c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment