Is it possible to configure Git to remind me that my stash is not empty when I'm launching some Git commands, let's say, for example, when I'm switching branches?
1 Answer
Some commands can invoke githooks.
Switching branches is usually done by git checkout <branch>. The hook post-checkout is invoked if it exists and is executable when git checkout is run. Copy the following script and paste to .git/hooks/post-checkout, and run chmod 755 .git/hooks/post-checkout.
#!/bin/bash oldrev=$1 newrev=$2 flag=$3 # list stashes if switching branches if [[ "${flag}" = 1 ]];then git stash list fi Then when you run git checkout <branch>, git stash list will be run and print the stash entries if any.
1 Comment
Marcelo Idemax
I was about to post the same thing! We got it faster...! :D