不同版本的暂存区? [英] Different versions staging area?
问题描述
我在某处看到每个git add
是一个新快照.
I read somewhere that each git add
is a new snapshot.
因此,如果在文件X上进行了一些更改,一个git add
,更多的更改,另一个git add
,我如何看到第一次调用和第二次调用git add
之间的更改?
So, if on file X, I do some changes, a git add
, more changes and another git add
, how can I see the changes between the first and second call to git add
?
推荐答案
您可能使用 Git内部-维护和数据恢复".
这类似于"执行git reset --hard HEAD^
后恢复添加的文件".
This is similar to "Recovering added file after doing git reset --hard HEAD^
".
如果已将对象添加到索引中(使用
git add
),则存在针对该对象状态创建的Blob-但是没有树(因此,提交)对象引用.
这就是获取悬挂"的松散对象文件的方式,如果运行git fsck
,它将显示未引用的blob(如果运行git gc将会删除这些类型的对象).
if you've added the object to the index (by using
git add
), there is a blob created for that state of the object - but there is no tree (and thus, commit) object that is referring to it.
This is how one gets a 'dangling' loose object file, and if you rungit fsck
it will show you the unreferenced blob (git gc will delete these types of objects if it is run).
因此,您可以轻松找到那些中间版本,因为没有文件 name 引用这些中间版本(因为没有树,只有斑点):您必须查看它们的内容.
So you can find those intermediate versions easily, because there isn't an file name referring those (since there is no tree, only blob): you have to look at their content.
这篇关于不同版本的暂存区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!