【发布时间】:2017-08-24 01:53:52
【问题描述】:
这是对以下内容的跟进:
How do I fetch only one branch of a remote git repository?
哪些参考:
https://www.kernel.org/pub/software/scm/git/docs/git-fetch.html
这依赖于理解 git fetch 的 refspec 使用模式:
git fetch [<options>] [<repository> [<refspec>…]]
要了解这种使用模式,需要了解“refspec”。例如:
被问到的问题是如何获取(远程存储库的)单个分支,有一个流行的答案:
git fetch <remote_name> <branch_name>
这个答案也很受欢迎:
git remote add -t <remote-branch-name> <remote-name> <remote-url>
我的问题是:如何从 git fetch 和 refspec 文档中找到第一个表单?
我之所以这么问,是因为“git fetch”是一个非常基本的 git 操作,是 git 初学者的入门命令之一,我发现自己无法获得对该命令的充分解释。
【问题讨论】:
-
请参阅kernel.org/pub/software/scm/git/docs/git-fetch.html 中的“已配置远程跟踪分支”。还有
The format of a <refspec> parameter is an optional plus +, followed by the source ref <src>, followed by a colon :, followed by the destination ref <dst>. The colon can be omitted when <dst> is empty.