git - 如何获取本地 PC 上的所有远程分支?

标签 git

我有一个非常大的存储库。为了克隆它,我从上到下依次使用了以下命令。

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/

相关文章:

git - 从 .git 目录生成工作目录文件

android - 每当我在 git 中提交时,如何清除 $HOME/.gradle/caches/?

git - Jenkins 在从 gitHub 克隆时出错

git - 在有和没有分支起点的情况下使用 `git checkout -b`

git - 如何用 github 上的存储库覆盖我的本地存储库?

git - 如何查看我的存储库中最近标记的提交?

java - 如何使用 JGit 获取文件更改列表?

git - 有没有办法直接在 Git 存储库中存储提交评论(比如在 GitHub 上)?

git - 如何修复丢失的 NuGet 包错误?

python - 属性错误: 'NoneType' object has no attribute 'split' while execute pelican-quickstart