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

后端 未结 9 1133
既然无缘
既然无缘 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:50

    i'd do a test on this:

    git diff --quiet --cached
    

    or this to be explicit:

    git diff --quiet --exit-code --cached
    

    where:

    --exit-code

    Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.

    --quiet

    Disable all output of the program. Implies --exit-code

提交回复
热议问题