我用 git fetch 获取了什么?
背景:我已经使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您正在将代表传入更改的提交对象提取到您的存储库的本地副本。实际数据存储在
.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 yougit-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.
来自 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.您正在获取存储在
.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
).