我有一个非常大的存储库。为了克隆它,我从上到下依次使用了以下命令。
git clone --depth=1 <url>
git fetch --depth=100
git fetch --depth=1000
git fetch --unshallow
git fetch origin
git pull --all
但我无法从远程获取所有分支。我只能通过 git branch -a
命令查看以下分支
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
如何从远程获取所有分支?
最佳答案
根据您对错误的评论,可以在 fatal: early EOF fatal: index-pack failed 找到部分答案。 , 通过 ingyhere .由于您想要所有分支,因此需要添加一个标志。运行
git clone --depth=1 --no-single-branch <url>
git branch -a
确保在继续之前看到所有分支。 no-single-branch
是重要的加法。
来自男人:
--depth depth
Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.
single-branch
默认为 Remote 的主 HEAD,在您的情况下为 master。
这将获得所有提交,以便您在每个分支中都有一个提交。我不确定它们是否会连接。现在你可以一个一个地 pull 它们,或者
git fetch --unshallow
git pull --all
按照上面的回答。上面的答案还指出
git config --global core.compression 0
在万一失败之前,一切都可能有所帮助。
关于git - 如何获取本地 PC 上的所有远程分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49747540/