Created
March 5, 2013 14:30
-
-
Save blazetopher/5090672 to your computer and use it in GitHub Desktop.
A git command for creating and popping a WIP (Work In Progress) commit. Install by placing somewhere on your PATH. Invoke with "git wip" or "git wip pop"
This file contains hidden or 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/sh | |
DO_POP=False | |
if [ "$1" = "pop" ]; then | |
DO_POP=True | |
fi | |
LAST_NAME=$(git log -1 --pretty=%B 2> /dev/null | awk "{ print \$1 }") | |
if [ "$LAST_NAME" = "WIP" ]; then | |
if $DO_POP; then | |
git reset HEAD^ | |
exit 0 | |
else | |
echo "WIP commit already present; aborting" | |
exit 1 | |
fi | |
else | |
if $DO_POP; then | |
echo "Cannot pop - last commit not WIP" | |
echo | |
echo `git log -1` | |
exit 1 | |
else | |
git commit -am "WIP" | |
exit 0 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment