这个问题可能是关于bash的,也是关于git的。
如果没有要提交的内容,如何运行命令?我执行了以下操作,但是它运行echo hello命令,即使没有什么可提交的:
if git diff --exit-code; then
echo hello
fi来自python背景,我认为如果git ...命令是空的,那么if语句中的内容就不会执行。我已经确认git diff --exit-code什么也不返回。
发布于 2022-03-02 00:08:29
试着做这样的事情:
git diff --exit-code # exit code will be "0" if no changes
if [ $? -gt 0 ]; then
echo hello
fihttps://stackoverflow.com/questions/71315985
复制相似问题