Skip to content

Instantly share code, notes, and snippets.

@blazetopher
Created March 5, 2013 14:30
Show Gist options
  • Save blazetopher/5090672 to your computer and use it in GitHub Desktop.
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"
#!/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