V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
miv
V2EX  ›  Linux

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

  •  
  •   miv · 2021-03-21 10:42:51 +08:00 · 1767 次点击
    这是一个创建于 1125 天前的主题,其中的信息可能已经有所发展或是发生改变。
    错误如下
    ```
    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
    ```
    9 条回复    2021-03-21 13:37:29 +08:00
    miv
        1
    miv  
    OP
       2021-03-21 10:43:21 +08:00
    在 Linux 下使用 bash 命令更新 git 仓库报错
    miv
        2
    miv  
    OP
       2021-03-21 10:43:37 +08:00
    应该是 cd 无效,请问有什么办法
    SenLief
        3
    SenLief  
       2021-03-21 10:44:10 +08:00
    你可能访问不到 github.com 了,
    ssh -T github.com
    SenLief
        4
    SenLief  
       2021-03-21 10:46:05 +08:00   ❤️ 1
    Sorry,应该是&&。
    miv
        5
    miv  
    OP
       2021-03-21 10:47:29 +08:00
    @SenLief #4 感谢感谢,正常了。
    dzdh
        6
    dzdh  
       2021-03-21 10:56:13 +08:00   ❤️ 4
    提供个额外小知识

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

    -C 参数在 git2.x 以上版本支持
    BrettD
        7
    BrettD  
       2021-03-21 13:32:35 +08:00
    一个&的意思是并行同时执行命令,而不是前后顺序
    snuglove
        8
    snuglove  
       2021-03-21 13:36:21 +08:00
    &是防后台执行的意思
    #!/bin/bash
    echo "更新项目"
    cd /home/ubuntu/my-project && git pull origin master
    miv
        9
    miv  
    OP
       2021-03-21 13:37:29 +08:00
    @BrettD #7
    @snuglove #8
    感谢老哥们,现在明白了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1057 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:03 · PVG 07:03 · LAX 16:03 · JFK 19:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.