Skip to content

Instantly share code, notes, and snippets.

@Bahanix
Created June 4, 2018 11:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bahanix/c057abc4e66ef261b43f79188b85dfb9 to your computer and use it in GitHub Desktop.
Save Bahanix/c057abc4e66ef261b43f79188b85dfb9 to your computer and use it in GitHub Desktop.
post-checkout hook to display if you had stashed something on this branch
#!/bin/sh
STASH_NAME="$(git stash list | grep `git branch | grep \* | cut -d ' ' -f2` | head -n1 | cut -d':' -f1)"
if [ -n "$STASH_NAME" ]
then
echo "Last stash on this branch:"
git --no-pager stash show "$STASH_NAME" -p
echo "To keep your stash list clean, consider using one of the followings:"
echo "git stash pop \"$STASH_NAME\""
echo "git stash drop \"$STASH_NAME\""
fi
@orent
Copy link

orent commented Jun 5, 2018

    BRANCH=$(git symbolic-ref --short HEAD)
    STASH_NAME=$(git log -g -1 --format=%gd --grep="WIP on $BRANCH:" refs/stash)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment