3

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 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I was about to post the same thing! We got it faster...! :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.