在使用 git fetch --no-tags 获取 repo 后检查一个分支

Checking out a branch after repo was fetched using git fetch --no-tags

我在这样获取的回购中(我无法控制此结帐)

git init
git fetch --no-tags --progress https://myrepo.git +refs/heads/someOtherBranch:refs/remotes/origin/someOtherBranch

这个回购协议中还有一个 develop 分支,我想结帐但是当我 运行 以下任意组合时,我得到 error: pathspec 'develop' did not match any file(s) known to git

git fetch
git checkout develop
git checkout origin/develop

如何检查开发分支(不通过 git clone 等)?

由于缺少一些配置变量,git fetch 没有任何其他选项无法按预期工作。对于克隆的存储库,会自动设置变量及其值 remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*,并自动添加默认远程 origin

在您的情况下,您可以指定遥控器和参考规格,

git fetch https://myrepo.git +refs/heads/develop:refs/remotes/origin/develop
git checkout develop

您也可以使用

git fetch https://myrepo.git develop
git checkout -b develop FETCH_HEAD