GIT 一行中多个命令错误

标签 git macos shell

当我运行 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/

相关文章:

git - 你如何组织你的 git 仓库?

git - 上游分支和远程跟踪分支有什么区别?

objective-c - 哪些 Cocoa View 和控件将创建类似于网络首选项显示的一部分 (Mac OS)?

macos - 按字母顺序对 NSPopUpMenu 项目进行排序

shell - 从路径中获取文件名

java - 使用控制台使用git,使用IDE(Eclipse)开发时需要考虑哪些事项?

linux - git autodeploy 脚本在 ubuntu 上的 post-receive hook 中

java - Mac OS X 上的 Install4j J​​RE 位于 .install4j/jre.bundle 中

shell - AWK 将空列替换为下一行的列值

用于更改父 shell 目录的 Bash 脚本