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

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

    I'm using this in a script to have:

    • 0 when everything is clean
    • 1 when there is a diff or untracked files

      [ -z "$(git status --porcelain)" ]

提交回复
热议问题