Last active
August 29, 2015 14:01
-
-
Save changa/6f9e3dd8c36b89f4b0d6 to your computer and use it in GitHub Desktop.
Git-wip : git stash straight to a dedicated branch
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/sh | |
# vim: set ft=sh : | |
if [ $# -ne 1 ]; then | |
echo "List of WIP branches:" | |
git branch|grep -e '^wip_' | |
else | |
if [ -z "$(git ls-files)" ]; then | |
echo "No files to stash in the staging area" >&2 | |
exit 1 | |
fi | |
new_branch_name="wip_${1}" | |
git stash --quiet && \ | |
git checkout --quiet -b $new_branch_name && \ | |
git stash pop --quiet && \ | |
git commit --quiet -am "WIP" && \ | |
git checkout --quiet - | |
echo "Stored files in ${new_branch_name} branch" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment