GIT新手:git fetch还没有拉取数据到本地?

发布于 2024-12-09 18:26:55 字数 449 浏览 1 评论 0原文

远程存储库有两个分支:ma​​sterdevelop

然后,我通过 gitbranch 检查了我的本地分支,我注意到我只有 master 分支,所以我运行命令 git fetch origin 。

之后,当我再次运行“gitbranch”时,我仍然只看到ma​​ster分支,为什么,不是“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

昨迟人 2024-12-16 18:26:55

是的,当您运行 git fetch origin 时,git 只是更新所有所谓的“远程跟踪分支” - 这些分支看起来像 origin/develop 和 < code>origin/master,您可以在 gitbranch -r 的输出中看到。您不能直接在这些分支机构上工作,尽管在许多其他方面您可以像本地分支机构一样使用它们。如果你想在开发分支上工作,你必须创建一个基于origin/develop的本地分支。使用 git 的所有有用的“Do What I Mean”快捷方式,您通常只需使用以下命令即可执行此操作:

git checkout develop

...尽管该命令的更明确版本是:

git checkout --track -b develop origin/develop

Yes, when you run git fetch origin, git just updates all the so-called "remote-tracking branches" - those are the ones that look like origin/develop and origin/master that you can see in the output of git 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 on origin/develop. Using all of git's helpful "Do What I Mean" shortcuts, you can usually do this with just:

git checkout develop

... although the more explicit version of that command would be:

git checkout --track -b develop origin/develop
〆凄凉。 2024-12-16 18:26:55

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文