Created
October 29, 2024 11:23
-
-
Save thomasaarholt/0ce51467ec9dbc7ac1f57353ed5a76cf to your computer and use it in GitHub Desktop.
The following code will print if you have any stashed code on a given branch. Add it to a repo's git/hooks/post-checkout to print whenever you change 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
# print stashes that exist for the currently switched-to branch | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
stashes=`git stash list | grep "WIP on $branch"` | |
if [ "$stashes" ] | |
then | |
echo "${GREEN}You have the following stashes for this branch:" | |
echo "${stashes}${NC}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment