Created
June 15, 2017 22:00
-
-
Save oreoshake/0e8de9f8bb535dbdd06eaae27297cb77 to your computer and use it in GitHub Desktop.
Automatically restore your working state from the last time you pulled a `git commit -am "wip"`
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
#!/bin/bash | |
set -e | |
prevHEAD=$1 | |
newHEAD=$2 | |
checkoutType=$3 | |
[[ $checkoutType == 1 ]] && checkoutType='branch' || | |
checkoutType='file' ; | |
if [ $checkoutType == 'branch' ]; then | |
clean=`git status --porcelain` | |
if [ -z "$clean" ]; then | |
wip=`git log --oneline -n 1 | cut -d" " -f2` | |
if [ $wip == "wip" ]; then | |
echo "WIP commit found, rolling back" | |
git reset HEAD^ | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment