我用 git fetch 获取了什么?

发布于 2024-12-09 15:31:36 字数 316 浏览 0 评论 0原文

背景:我已经使用 git 大约 6 个月了,表面上我对它很满意。然而,我正在做的一些事情仍然是黑匣子巫毒,我想更好地理解。

当我运行类似的东西时,

git fetch upstream
git merge upstream/master

我知道这相当于拉动。首先获取一些东西,然后我用它来执行合并。

我不明白的是我要获取的是什么,这些信息位于哪里?我从概念上理解我正在获取上游远程存储库上的所有分支,但似乎该信息需要存在某个地方,而这就是我的大脑和对 git 的理解只能想出“我用 git Fetch 获取什么” ?”

Context: I've been using git for about 6 months and I'm comfortable with it on a surface level. However, some of what I'm doing is still black box voodoo that I'd like to understand better.

When I run something like

git fetch upstream
git merge upstream/master

I understand this is the equivalent of a pull. First a fetch something, then I use that something to perform the merge.

What I don't understand is what IS it I'm fetching, and where does this information live? I understand conceptually I'm fetching all the branches on the upstream remote repository, but it seems like that information would need to live somewhere, and that's where my brain and understanding of git can only come up with "What am I Fetching with git Fetch?"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

拧巴小姐 2024-12-16 15:31:36

您正在将代表传入更改的提交对象提取到您的存储库的本地副本。实际数据存储在 .git 目录下,直到您 git-merge,此时它也会出现在工作目录中。


想知道所有血淋淋的细节吗?请查看 Pro Git,第 9 章:Git 内部原理

You're fetching commit objects which represent the incoming changes, into your local copy of the repository. The actual data is stored under the .git directory, until you git-merge, at which point it will also be represented in the working directory.


Want to know all the gory details? Check out Pro Git, Chapter 9: Git Internals.

甜嗑 2024-12-16 15:31:36

来自 fetch 的信息被填充到 .git 文件夹中,就像它是另一个分支一样。本地存储库保存有关所有分支的提交的信息,包括从远程存储库获取的分支。

The information from fetch is stuffed in .git folder, as if it was another branch. The local repository holds information about commits of all branches, including the branches that are fetched from remote repositories.

陪我终i 2024-12-16 15:31:36

您正在获取存储在 .git/objects 目录中的 git 对象以及有关远程头对象 (.git/FETCH_HEAD) 的信息。

You're fetching git objects, stored in .git/objects directory, and the information about remote head object (.git/FETCH_HEAD).

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