git 合并命令以 1 退出,如果它已经是最新的

git merge command exits with 1, if it is already up to do date

我有这个命令:

git merge "remotes/origin/dev"; echo $?

我得到:

On branch oleg/feature/1537472700
Your branch is up to date with 'origin/oleg/feature/1537472700'.

nothing to commit, working tree clean
1

为什么以1退出?知道一切正常的唯一方法是解析 stdout/stderr?

git merge 如果您的分支是最新的,则成功退出(即 0)。您看到的消息 "nothing to commit, working tree clean" 来自 git commit,如果没有任何内容可提交,它确实会退出 1。

您可能有某种挂钩或 shell 包装器正在调用 git commit,这似乎是您的非零退出代码的来源。