git存储提交对象中的差异信息? [英] does git store diff information in commit objects?

查看:112
本文介绍了git存储提交对象中的差异信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个


需要注意的是,这与您可能熟悉的大多数SCM
系统非常不同。 Subversion,CVS,Perforce,
Mercurial等都使用Delta Storage系统 - 它们存储
之间的差异。 Git不会执行
这个 - 它存储了每次提交时,在您的项目
中所有文件看起来像这个树结构的快照。这是一个
非常重要的概念,在使用Git时需要理解。


然而,当我运行 git显示$ SHA1ofCommitObject ...

 提交4405aa474fff8247607d0bf599e054173da84113 
作者:Joe Smoe< jo .smoe @ example.com>
日期:星期二5月1日08:48:21 2012 -0500

第一次提交

diff --git a / index.html b / index.html
新文件模式100644
索引0000000..de8b69b
--- / dev / null
+++ b / index.html
@@ -0,0 + 1 @@
+< h1> Hello World!< / h1>
diff --git a / interests / chess.html b / interests / chess.html
新文件模式100644
索引0000000..e5be7dd
--- / dev / null
+++ b / interest / chess.html
@@ -0,0 +1 @@
+您在Slashdot看到King's Gambit接受的解决方案! < a href =http:// game

...它输出提交的差异我知道git不会在blob对象中存储差异,但它是否将差异存储在提交对象中?或者是 git show 动态计算差异?<解决方案

不,git中的提交对象不包含差异 - 相反,每个提交对象都包含树的哈希,它递归地并完全定义了该提交处的源代码树的内容。有一个在git社区书中提供了很好的解释,了解blob对象,树对象和提交对象的含义。



所有显示给你的差异git的工具是根据文件的完整内容按需计算的。


According to this:

It is important to note that this is very different from most SCM systems that you may be familiar with. Subversion, CVS, Perforce, Mercurial and the like all use Delta Storage systems - they store the differences between one commit and the next. Git does not do this - it stores a snapshot of what all the files in your project look like in this tree structure each time you commit. This is a very important concept to understand when using Git.

Yet when I run git show $SHA1ofCommitObject...

commit 4405aa474fff8247607d0bf599e054173da84113
Author: Joe Smoe <joe.smoe@example.com>
Date:   Tue May 1 08:48:21 2012 -0500

    First commit

diff --git a/index.html b/index.html
new file mode 100644
index 0000000..de8b69b
--- /dev/null
+++ b/index.html
@@ -0,0 +1 @@
+<h1>Hello World!</h1>
diff --git a/interests/chess.html b/interests/chess.html
new file mode 100644
index 0000000..e5be7dd
--- /dev/null
+++ b/interests/chess.html
@@ -0,0 +1 @@
+Did you see on Slashdot that King's Gambit accepted is solved! <a href="http://game

... it outputs the diff of the commit with the previous commits. I know that git doesn't store diffs in blob objects, but does it store diffs in commit objects? Or is git show dynamically calculating the diff?

解决方案

No, commit objects in git don't contain diffs - instead, each commit object contains a hash of the tree, which recursively and completely defines the content of the source tree at that commit. There's a nice explanation in the git community book of what goes into blob objects, tree objects and commit objects .

All the diffs that are shown to you by git's tools are calculated on demand from the complete content of files.

这篇关于git存储提交对象中的差异信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆