[英]How is it clear which of the files listed in a git tree are part of a specific commit?
A commit in git has a reference to a tree and that tree references blobs or other trees and captures a "snapshot" of the project. git中的提交引用了树,该树引用了blob或其他树并捕获了项目的“快照”。
What I am not clear about is how the association is done between a specific commit with the actual files affected by the commit. 我尚不清楚的是如何在特定提交与受该提交影响的实际文件之间建立关联。
Example in my project I have the files README
and notes.txt
. 在我的项目中,示例有
README
和notes.txt
文件。
If I add a new file eg contracts.txt
and commit it I would have the new commit XYZ
and if I did git show XYZ
I would see only the file contracts.txt
listed. 如果我添加一个新文件,例如
contracts.txt
并提交,我将拥有新的提交XYZ
,如果我进行git show XYZ
我只会看到列出的文件contracts.txt
。
But if I do git cat-file -p XYZ
I would see that its associated tree is ABC
which doing git cat-file -p ABC
would show: 但是,如果我执行
git cat-file -p XYZ
我会看到它的关联树是ABC
,执行git cat-file -p ABC
将会显示:
blob F123 README
blob A0F8 notes.txt
blob DA03 contract.txt
So I can't tell from this how could we figure out that from these 3 reported blobs reported as part of the tree, only DA03 contract.txt
was added as part of the commit XYZ
. 因此,我不能从中知道如何从这三个报告为树的一部分的报告斑点中
DA03 contract.txt
作为提交XYZ
一部分。
How is the association done? 关联如何完成?
Simply: by comparing with the same information from the parent commit. 简单:通过与父提交中的相同信息进行比较。 For merges, the comparison is done with all the parents.
对于合并,将与所有父母进行比较。 Only blobs which don't come from either (thus are new files or new versions thereof; in the case of merges, also resolutions of merge conflicts) are shown by
git show
. git show
仅显示不来自两者的Blob(因此是新文件或新版本;在合并的情况下,也是合并冲突的解决方案)。
What I am not clear about is how the association is done between a specific commit with the actual files affected by the commit.
我尚不清楚的是如何在特定提交与受该提交影响的实际文件之间建立关联。
Git does not make such associations, it simply stores the snapshot of the repository for each commit. Git没有建立这种关联,它只是为每次提交存储存储库的快照。 Diff tools display the files as new if they don't exist in the parent commit.
如果父提交中不存在差异工具,则它们会将文件显示为新文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.