我如何“撤销”?一个 - 单分支克隆? [英] How do I "undo" a --single-branch clone?
问题描述
git clone -b<分支名称>来克隆回购。 --single-branch< github url> < target directory>
这只克隆了这个分支,但现在我想切换到主分支和其他分支。除了清除它并开始克隆其余的回购,我可以撤销--single-branch首选项吗?
你可以告诉Git如下所示的所有分支: git config remote.origin.fetch+ refs / heads / *:refs / remotes / origin / *
git fetch origin
如果你看看 .git / config
,它看起来像这样:
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remoteorigin]
url = https://github.com/owner/repo.git
fetch = + refs / heads / master:refs / remotes / origin / master
[branchmaster]
remote = origin
merge = refs / heads / master
rebase = true
我将它与完整的克隆进行了比较,并且看到了t他唯一的区别就是 [remoteorigin]下的fetch
。
注意: Git版本1.8.2。如果您运行的是较旧版本的Git,配置选项可能已更改。如果我的命令不起作用,那么我建议查看 .git / config
以查看是否可以看到类似的内容。
I cloned a repo using the
git clone -b <branch name> --single-branch <github url> <target directory>
This cloned ONLY this branch, but now I want to switch to the master and other branches. Is there any way besides clearing it out and starting over to clone the rest of the repo that I can undo the --single-branch preference?
You can tell Git to pull all branches like this:
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin
If you look in .git/config
, it'll look something like this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remote "origin"]
url = https://github.com/owner/repo.git
fetch = +refs/heads/master:refs/remotes/origin/master
[branch "master"]
remote = origin
merge = refs/heads/master
rebase = true
I compared this to a full clone, and saw that the only difference was the "fetch" under [remote "origin"]
.
Note: I'm running Git version 1.8.2. The config options may have changed if you're running an older version of Git. If my commands don't work, then I'd recommend looking through .git/config
to see if you can see something similar.
这篇关于我如何“撤销”?一个 - 单分支克隆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!