8

我设置了一个这样的 git 别名:

git config --global alias.popmerge '!git stash pop && git merge master'

然后我这样称呼它:

git popmerge

git stash pop ”被执行,但“ git merge master ”被忽略。

如果我在“ git popmerge ”之后立即运行“ git merge master ”......它按预期运行,执行合并。

我还有其他具有长命令序列的别名......它们运行完美。似乎“ git stash pop ”中的某些东西使别名进程停止......是否可以避免这种行为?如何?

谢谢。

4

1 回答 1

8

您是否检查过 stash pop 的退出代码?

&&意味着仅当退出代码为 0(成功)时才执行后续列表。

您可以使用;而不是简单地忽略退出代码&&


使用以下内容验证成功:

true  && echo ok || echo fail   # echoes "ok"

false && echo ok || echo fail   # echoes "fail"
于 2011-05-25T15:27:43.400 回答