【问题标题】:Would `git remote add --mirror=fetch` make same repo with `git clone --mirror`?`git remote add --mirror=fetch` 会与 `git clone --mirror` 制作相同的仓库吗?
【发布时间】:2020-11-24 06:18:31
【问题描述】:

如果我想复制一个 repo,我会使用这个。

git clone --mirror $SRC $DST

但此命令要求$DST 不存在 repo。通常没问题,但如果我想从多个进程同时发出 Git 命令,可能会导致一些竞争条件,因为在执行命令之前不存在可锁定的文件对象。

如果我只想跳过$DST 的存在测试,我想我可以做到

mkdir -p $DST
cd $DST
git init --bare 
git remote add origin --mirror-=fetch $SRC 2>/dev/null || true
git remote update

这会与git clone --mirror $SRC $DST 生成完全相同的回购吗?

【问题讨论】:

    标签: git concurrency git-clone mirror git-mirror


    【解决方案1】:

    如果您查看test done for a git clone --mirror,您会看到镜像克隆是一个:

    • fetch refspec 设置为 +refs/*:refs/*
    • git config --bool remote.origin.mirror 设置为 true

    如果在你的 git 远程命令之后满足这些条件,那么是的,这将相当于一个镜像克隆。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-21
      • 2011-09-03
      • 2021-11-17
      • 2011-06-18
      • 2017-05-30
      • 1970-01-01
      • 2020-04-29
      • 2019-04-25
      相关资源
      最近更新 更多