V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
miv
V2EX  ›  Linux

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

  •  
  •   miv · Mar 21, 2021 · 2203 views
    This topic created in 1871 days ago, the information mentioned may be changed or developed.
    错误如下
    ```
    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 replies    2021-03-21 13:37:29 +08:00
    miv
        1
    miv  
    OP
       Mar 21, 2021
    在 Linux 下使用 bash 命令更新 git 仓库报错
    miv
        2
    miv  
    OP
       Mar 21, 2021
    应该是 cd 无效,请问有什么办法
    SenLief
        3
    SenLief  
       Mar 21, 2021
    你可能访问不到 github.com 了,
    ssh -T github.com
    SenLief
        4
    SenLief  
       Mar 21, 2021   ❤️ 1
    Sorry,应该是&&。
    miv
        5
    miv  
    OP
       Mar 21, 2021
    @SenLief #4 感谢感谢,正常了。
    dzdh
        6
    dzdh  
       Mar 21, 2021   ❤️ 4
    提供个额外小知识

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

    -C 参数在 git2.x 以上版本支持
    BrettD
        7
    BrettD  
       Mar 21, 2021
    一个&的意思是并行同时执行命令,而不是前后顺序
    snuglove
        8
    snuglove  
       Mar 21, 2021
    &是防后台执行的意思
    #!/bin/bash
    echo "更新项目"
    cd /home/ubuntu/my-project && git pull origin master
    miv
        9
    miv  
    OP
       Mar 21, 2021
    @BrettD #7
    @snuglove #8
    感谢老哥们,现在明白了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2777 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 06:02 · PVG 14:02 · LAX 23:02 · JFK 02:02
    ♥ Do have faith in what you're doing.