How can you find out if git stash is needed more?

Is it possible to indicate whether the glue has already been applied, and therefore is no longer required without doing git stash apply ? Suppose I use only one branch.

This can be prevented with pop , rather than apply when using the wallet, and therefore, every time it is applied, it will get rid of the wallet. However, I sometimes use git stash to save a snapshot of the current job, and not just use it to switch from one task to another. Using pop can overcome this somewhat.

+8
git git-stash
source share
2 answers

Just make a diff and you will see.

git diff HEAD stash @ {0}

+9
source share

You can use the following shell script to get a git stash list with prefixes with checkmarks if they have already been applied or there is no need to apply them, since there is no difference.

 git stash list | while read line; do \ ref=${line%%:*}; \ prefix=$(test $(git diff $ref | wc -l) = "0" && echo "✔ " || echo " "); \ echo "$prefix$line"; \ done 

This will give you a list like:

 ✔ stash@{0}: WIP on develop: 77a1a66 send 'social.share' message via 'view-req-relay'... stash@{1}: WIP on bigcouch: 4bfa3af added couchdb filters... 

And if you like it, you can add it as a git alias:

 git config --global --add alias.stash-list '!git stash list | while read line; do ref=${line%%:*}; prefix=$(test $(git diff $ref | wc -l) = "0" && echo "✔ " || echo " "); echo "$prefix$line"; done' git stash-list 

(verified using bash and zsh )

+4
source share

All Articles