Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
miv
V2EX  ›  Linux

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

  •  
  •   miv · Mar 21, 2021 · 2635 views
    This topic created in 2058 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
    miv
    OP
    Mar 21, 2021
    1
    在 Linux 下使用 bash 命令更新 git 仓库报错
    miv
    miv
    OP
    Mar 21, 2021
    2
    应该是 cd 无效,请问有什么办法
    SenLief
    SenLief
    Mar 21, 2021
    3
    你可能访问不到 github.com 了,
    ssh -T github.com
    SenLief
    SenLief
    Mar 21, 2021❤️1
    4
    Sorry,应该是&&。
    miv
    miv
    OP
    Mar 21, 2021
    5
    @SenLief #4 感谢感谢,正常了。
    dzdh
    dzdh
    Mar 21, 2021❤️4
    6
    提供个额外小知识

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

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