[英]Why does “git pull” get all branches from repository but “git pull origin master” not do so?
Why does git pull
get all branches from repository but git pull origin master
doesn't?为什么git pull
从存储库中获取所有分支而git pull origin master
没有? I discovered it the hard way.我以艰难的方式发现了它。 Is it the only functional difference between these two commands?这是这两个命令之间唯一的功能区别吗?
Explanation like this tells me nothing:像这样的解释什么也没告诉我:
git pull
= git fetch origin
+ git merge origin/master
git pull
= git fetch origin
+ git merge origin/master
git pull origin master
= git fetch origin master
+ git merge FETCH_HEAD
git pull origin master
= git fetch origin master
+ git merge FETCH_HEAD
The latter command, git pull origin master
, tells git to fetch and merge specifically the master
branch (from the remote named origin
, to be even more precise).后一个命令git pull origin master
告诉 git 专门获取和合并master
分支(从远程命名origin
,更准确地说)。
git pull
fetches updates for all local branches, which track remote branches, and then merges the current branch. git pull
获取所有本地分支的更新,跟踪远程分支,然后合并当前分支。
From the documentation of git pull
:从git pull
的 文档中:
git pull
runsgit fetch
with the given parameters and calls git merge to merge the retrieved branch heads into the current branchgit pull
使用给定的参数运行git fetch
并调用 git merge 将检索到的分支头合并到当前分支中
When you callgit fetch
without arguments, the following happens当您不带参数调用git fetch
,会发生以下情况
Fetches named heads or tags from one or more other repositories, along with the objects necessary to complete them.从一个或多个其他存储库中获取命名的头部或标签,以及完成它们所需的对象。
git fetch
[fetches] from (...) a single named repository (...)git fetch
[fetches] from (...) 单个命名存储库 (...)
When you add arguments, only the specified remote and head (=branch/tag/commit/...) are fetched, and then merged.添加参数时,仅获取指定的远程和头 (=branch/tag/commit/...),然后合并。
Git pull only pulls the checkout branch. Git pull 只拉取结帐分支。
If you want to update all local branches with origin remote branches.如果要使用原始远程分支更新所有本地分支。
git pull --all
Can "git pull --all" update all my local branches? “git pull --all”可以更新我所有的本地分支吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.