当我运行 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时,没有问题。
最佳答案
shell 中命令后的单个与号(&
) 表示在后台运行该命令。从日志中,您可以看到作业/进程进入后台,这使得命令可以并行运行
<user> alexis$ git add . & git commit -m "Add some fix" & git push
[1] 32595
[2] 32596
其中&&
在shell中表示“逻辑与”,||
表示“逻辑或”。您可以发现它们在许多启动/初始化脚本中得到了明智的使用,例如(jboss,tomcat)
[ -f "$file" ] && cat $file # cat the file only the file exists and regular file
关于GIT 一行中多个命令错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50230513/