在 Linux 下使用 bash 命令更新 git 参考报错.

2021-03-21 10:42:51 +08:00
 miv
错误如下
```
fatal: not a git repository (or any of the parent directories): .git
```

bash 脚本如下
```
#!/bin/bash
echo "更新项目" &
cd /home/ubuntu/my-project &
git pull origin master
```
1781 次点击
所在节点    Linux
9 条回复
miv
2021-03-21 10:43:21 +08:00
在 Linux 下使用 bash 命令更新 git 仓库报错
miv
2021-03-21 10:43:37 +08:00
应该是 cd 无效,请问有什么办法
SenLief
2021-03-21 10:44:10 +08:00
你可能访问不到 github.com 了,
ssh -T github.com
SenLief
2021-03-21 10:46:05 +08:00
Sorry,应该是&&。
miv
2021-03-21 10:47:29 +08:00
@SenLief #4 感谢感谢,正常了。
dzdh
2021-03-21 10:56:13 +08:00
提供个额外小知识

git 有个 -C(大写) 参数可以执行工作路径的如 `git -C /home/ubuntu/my-project pull origin master`

-C 参数在 git2.x 以上版本支持
BrettD
2021-03-21 13:32:35 +08:00
一个&的意思是并行同时执行命令,而不是前后顺序
snuglove
2021-03-21 13:36:21 +08:00
&是防后台执行的意思
#!/bin/bash
echo "更新项目"
cd /home/ubuntu/my-project && git pull origin master
miv
2021-03-21 13:37:29 +08:00
@BrettD #7
@snuglove #8
感谢老哥们,现在明白了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/763597

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX