Skip to content

Instantly share code, notes, and snippets.

@kipras
Created June 13, 2014 10:37
Show Gist options
  • Save kipras/125b131699af2fd44534 to your computer and use it in GitHub Desktop.
Save kipras/125b131699af2fd44534 to your computer and use it in GitHub Desktop.
git-stash-push
#!/bin/sh
#
# git-stash-push
# Push working tree onto the stash without modifying working tree.
# First argument (optional) is the stash message.
if [ -n "$1" ]; then
git update-ref -m "$1" refs/stash "$(git stash create \"$1\")"
else
HASH=`git stash create`
MESSAGE=`git log --no-walk --pretty="tformat:%-s" "$HASH"`
git update-ref -m "$MESSAGE" refs/stash "$HASH"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment