有两个命令的Git别名(隐藏弹出+合并)只执行第一个命令。为什么?如何执行合并? [英] Git alias with two commands (stash pop + merge) executes only the first command. Why? How to execute also the merge?

查看:151
本文介绍了有两个命令的Git别名(隐藏弹出+合并)只执行第一个命令。为什么?如何执行合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

$ g $ git config --global alias.popmerge! ;&安培; git merge master'

然后我会这样称呼它:

  git popmerge 

git stash pop 被执行,但是 git merge master 被忽略。 如果我运行 git merge master 紧跟在 git popmerge 之后......它按预期顺序运行,并执行合并。

我有其他的长命令序列...他们完美无瑕地运行。看起来在 git stash pop 中有一些东西让别名进程暂停 ...是否可以避免这种行为?如何?



谢谢。

解决方案

从藏匿流行?



&& 意味着后续列表 如果退出代码为0(成功),则执行。



您可以通过使用; 而不是&安培;&安培;






通过使用以下内容验证成功:

  true&&回声确定||回声失败#回声ok

false&&回声确定||回声失败#回声失败


I set up a git alias like this:

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

Then I call it, like this:

git popmerge

The "git stash pop" is executed, but the "git merge master" is ignored.

If I run "git merge master" right after the "git popmerge"... it sumply runs as expected, performing the merge.

I have other aliases with long sequences of commands... and they run flawlessly. It seems something at "git stash pop" makes the alias process to halt... Is it possible to avoid this behavior? How?

Thanks.

解决方案

Have you checked the exit code from stash pop?

&& implies that the subsequent list is only executed if the exitcode is 0 (success).

You can simply ignore the exitcode by using ; instead of &&.


Verify the success by using stuff like:

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

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

这篇关于有两个命令的Git别名(隐藏弹出+合并)只执行第一个命令。为什么?如何执行合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆