【问题标题】:GIT multiple command in one line errorGIT多个命令在一行错误
【发布时间】:2018-10-18 05:20:24
【问题描述】:

当我运行git add . & git commit -m "some fix" & git push 时,它返回一个错误:

<user> alexis$ git add . & git commit -m "Add some fix" & git push
[1] 32595
[2] 32596
fatal: Unable to
create'/Users/<user>/Desktop/project/.git/index.lock': File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
Everything up-to-date
[1]-  Done                    git add .
[2]+  Exit 128                git commit -m "Add some fix"

当我把所有的cmd一个一个的执行完,就没问题了。

【问题讨论】:

  • 使用双 &amp;&amp; 而不是单一个。

标签: git macos shell


【解决方案1】:

shell 中命令后的单个 & 符号(&amp;) 表示在后台运行命令。从您的日志中,您可以看到作业/进程进入后台,这使得命令可以并行运行

<user> alexis$ git add . & git commit -m "Add some fix" & git push
[1] 32595
[2] 32596

shell 中的&amp;&amp; 表示“逻辑与”,|| 表示“逻辑或”。您可以在许多启动/初始化脚本(如(jboss,tomcat))中找到这些明智的使用

[ -f "$file" ] && cat $file # cat the file only the file exists and regular file

【讨论】:

    猜你喜欢
    • 2014-09-01
    • 2021-07-13
    • 2015-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-23
    • 2016-07-25
    • 2017-01-13
    相关资源
    最近更新 更多