GIT新手:git fetch还没有拉取数据到本地?
远程存储库有两个分支:master、develop。
然后,我通过 gitbranch 检查了我的本地分支,我注意到我只有 master 分支,所以我运行命令 git fetch origin 。
之后,当我再次运行“gitbranch
”时,我仍然只看到master分支,为什么,不是“gitbranch
”应该列出所有本地分支机构?
这是否意味着 git fetch origin 尚未将 develop 设为我的本地分支?那么 git fetch 到底在做什么呢?
(但我可以使用gitbranch-r
看到develop分支)
The remote repository has two branches: master, develop.
Then, I checked my local branch by git branch
, I notice I have only master branch, so I run command git fetch origin
.
After this, when I run "git branch
" again, I still see only master branch, why, isn't "git branch
" supposed to list all local branches?
Does it mean the git fetch origin
does not yet make the develop as my local branch? Then what git fetch
actually doing?
(But I can see develop branch with git branch -r
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,当您运行 git fetch origin 时,git 只是更新所有所谓的“远程跟踪分支” - 这些分支看起来像 origin/develop 和 < code>origin/master,您可以在 gitbranch -r 的输出中看到。您不能直接在这些分支机构上工作,尽管在许多其他方面您可以像本地分支机构一样使用它们。如果你想在开发分支上工作,你必须创建一个基于
origin/develop
的本地分支。使用 git 的所有有用的“Do What I Mean”快捷方式,您通常只需使用以下命令即可执行此操作:...尽管该命令的更明确版本是:
Yes, when you run
git fetch origin
, git just updates all the so-called "remote-tracking branches" - those are the ones that look likeorigin/develop
andorigin/master
that you can see in the output ofgit branch -r
. You can't work directly on those branches, although in many other respects you can use them like your local branches. If you want to work on the develop branch, you have to create a local branch based onorigin/develop
. Using all of git's helpful "Do What I Mean" shortcuts, you can usually do this with just:... although the more explicit version of that command would be:
git fetch
仅获取 git 对象。而已。在您的情况下,您必须创建一个本地分支并将其设置为跟踪远程分支。
git fetch
only fetches the git objects. Nothing more.In your case, you have to create a local branch and set it to track a remote branch.