min*_*hua 76 git branch shallow-clone
克隆远程存储库后,它不会通过-a选项显示任何远程分支.可能是什么问题呢?怎么调试呢?在此片段中,未显示两个远程分支:
$ git clone --depth 1 git://git.savannah.gnu.org/pythonwebkit.git
$ cd pythonwebkit
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
$ git --version
git version 1.8.3.1
Run Code Online (Sandbox Code Playgroud)
在另一台机器上尝试相同的命令,它运作良好:
$ git clone --depth 1 git://git.savannah.gnu.org/pythonwebkit.git
Receiving objects: 100% (186886/186886), 818.91 MiB | 3.44 MiB/s, done.
$ cd pythonwebkit/
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/debian
remotes/origin/master
remotes/origin/python_codegen
$ git --version
git version 1.7.1
Run Code Online (Sandbox Code Playgroud)
尝试克隆另一个回购,它运作良好.虽然我可以在这台机器上再试一次,但最好知道什么是错的.
任何建议或提示都将受到欢迎.
编辑:答案摘要:从git版本1.8.3.2开始,需要同时使用"--depth"和"--no-single-branch"来获得与以前相同的行为.这被视为错误修复.
mar*_*rlo 149
做了浅克隆后,能够从远程检出其他分支,
跑(感谢@jthill):
git remote set-branches origin '*'
Run Code Online (Sandbox Code Playgroud)在那之后,做一个 git fetch -v
最后 git checkout the-branch-i-ve-been-looking-for
步骤1也可以通过编辑手动完成.git/config.
例如,更改以下行:
fetch = +refs/heads/master:refs/remotes/origin/master
Run Code Online (Sandbox Code Playgroud)
到(替换master用*):
fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
Flo*_*sch 54
行为是正确的,在最后一次修订之后,master-branch(因为这是主要远程的HEAD)是存储库中唯一的远程分支:
florianb$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
Run Code Online (Sandbox Code Playgroud)
完整克隆提供新的(所有)分支:
florianb$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/debian
remotes/origin/master
remotes/origin/python_codegen
Run Code Online (Sandbox Code Playgroud)
由于技术文档中的浅层描述," git-clone --depth 20 repo[...]结果[s in]提交链的长度最多为20".因此,浅层克隆应该包含从分支的尖端请求的提交深度.
作为-除了-的文档git clone的--single-branch-option描述:
"仅克隆导致单个分支的提示的历史记录,由
--branch选项或主分支远程HEAD指向的点指定.当使用该--depth选项创建浅克隆时,这是默认值,除非--no-single-branch用于获取附近的历史记录.所有分支的提示. "
因此,一个浅克隆(带的深度 -选项)只取只有一个单一的分支(以您所要求的深度).
不幸的是,两个选项(--depth和--single-branch)在过去都是错误的,并且浅克隆的使用意味着未解决的问题(正如您在上面发布的链接中所读到的那样),这是由给定的历史重写引起的.在特殊情况下,这总体上导致一些复杂的行为.
ale*_*dnm 49
通过阅读@jthill的回复和评论,对我来说最有效的方法是使用命令中的set-branches选项git remote:
$ git clone --depth 1 https://github.com/dogescript/dogescript.git
$ git remote set-branches origin 'remote_branch_name'
$ git fetch --depth 1 origin remote_branch_name
$ git checkout remote_branch_name
Run Code Online (Sandbox Code Playgroud)
这会更改命名远程跟踪的分支列表,以便我们可以只获取和签出所需的分支.
| 归档时间: |
|
| 查看次数: |
44004 次 |
| 最近记录: |