How to check if there's nothing to be committed in the current branch?

后端 未结 9 1147
既然无缘
既然无缘 2020-12-22 15:57

The goal is to get an unambiguous status that can be evaluated in a shell command.

I tried git status but it always returns 0, even if there are items

9条回答
  •  星月不相逢
    2020-12-22 16:55

    Not pretty, but works:

    git status | grep -qF 'working directory clean' || echo "DIRTY"
    

    Not sure whether the message is locale dependent, so maybe put a LANG=C in front.

提交回复
热议问题