因此,我们经常通过有效地克隆单支克隆来优化克隆.然而,我们随后无法获得更多的分支。从管道的角度看,有和没有单支的git克隆人有什么区别?以后怎样才能取下更多的分支呢?
标准克隆人:
$ git clone -b branch-name https://repo.url standard
$ cd standard
$ git checkout remote-branch
Branch 'remote-branch' set up to track remote branch 'remote-branch' from 'origin'.
Switched to a new branch 'remote-branch'单支克隆人:
$ git clone -b branch-name --single-branch https://repo.url singlebranch
$ cd singlebranch
$ git checkout remote-branch
error: pathspec 'remote-branch' did not match any file(s) known to git更新
下面是@AndrewMarshall的回答,您需要在配置中更新默认的fetch refspec。即使您可以在fetch中以黑客的方式删除右提交,但是如果您不首先修复配置,那么尝试的签出绝对会拒绝了解有关该分支的任何信息:
$ git fetch origin +refs/heads/remote-branch:refs/remotes/origin/remote-branch
From https://gerrit.magicleap.com/a/platform/mlmanifest
* [new branch] remote-branch -> origin/remote-branch
$ git checkout remote-branch
error: pathspec 'remote-branch' did not match any file(s) known to git
$ git remote set-branches origin --add remote-branch
$ git checkout remote-branch
Branch 'remote-branch' set up to track remote branch 'remote-branch' from 'origin'.
Switched to a new branch 'remote-branch'注意,我们获取它,然后重新配置,然后签出。获取可以按任何顺序进行(尽管您必须传递参数(如果不是在配置中),但是签出是由配置设置的门控。
发布于 2019-03-26 02:12:58
--single-branch的工作方式是将远程的fetch属性设置为仅为单个分支名称,而不是glob:
$ git config --get-all remote.origin.fetch
+refs/heads/master:refs/remotes/origin/master所以让我们用git remote set-branches添加一个条目
$ git remote set-branches origin --add other-branch
$ git config --get-all remote.origin.fetch
+refs/heads/master:refs/remotes/origin/master
+refs/heads/other-branch:refs/remotes/origin/other-branch
$ git fetch
From origin
* [new branch] other-branch -> origin/other-branch
$ git checkout other-branch
Branch 'other-branch' set up to track remote branch 'other-branch' from 'origin'.
Switched to a new branch 'other-branch'或者,将其设置为glob,以便获取所有分支(默认的非单分支行为)(请注意,引用*是为了避免shell展开;glob用于git,而不是shell):
git remote set-branches origin '*'发布于 2022-04-30 13:22:25
非常简短的摘要:
$ git远程集-分支来源--添加其他分支 $ git提取
$ git结帐其他分行
https://stackoverflow.com/questions/55348731
复制相似问题