这是以下内容的后续内容:
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初学者的启动命令之一,而我发现自己很难对这个命令有一个充分的解释。
发布于 2017-08-24 01:53:52
如果要更新当前分支,则命令为
git pull origin master其中origin是远程存储库的名称,master是要获取并合并到当前分支中的分支的名称(假设当前分支是您的本地master)。
对于任何其他分支,该命令为
git fetch origin branch:branch这将从远程分支branch获取commits,更新本地远程跟踪分支origin/branch并更新本地分支branch。
https://stackoverflow.com/questions/45845254
复制相似问题