How can you tell if a git stash is no longer required?

感情迁移 提交于 2019-12-05 02:16:40

Just make a diff and you will see.

git diff HEAD stash@{0}

You can use the following shell script to get git stash list prefixed with checkmarks if they have already been applied or there is no need to apply them as 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 like that:

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

(tested with bash and zsh)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!