更新时间:2022-12-23 13:46:46
如 Git内部-Git对象,每次更改文件内容并将其添加到缓存时,做一个:
As described in "Git Internals - Git Objects", each time you change the content of a file, and add it to the cache, you do a:
git hash-object -w test.txt
将其存储到存储的对象中。
That stores it to the object stored.
我只是添加了两个 git
连续一个文件,然后是:
I just did two git add
consecutively for one file, followed by a:
C:\Users\VonC\prog\go\src\github.com\VonC\asciidocgo\.git>gfind -mmin -10 -print
.
./index
./objects/4f
./objects/4f/76d586459ec6ffc42257bb4c61d5422051cb10
./objects/61
./objects/61/24401794e7fee613f5a56593a0a8a059b2627a
(请注意 -mmin
参数查找自
我本可以在每次 git add
加上a后列出相同的sha1:
I could have listed those same sha1 after each git add
with a:
git rev-parse :0:abstractNode_test.go
请参见 git rev -parse
(和
See git rev-parse
(and "What does git rev-parse
do?"): adding a file in the index is stage 0 only (stage 1, 2 and 3 are used during a merge to record, still in the index, the common ancestor, source and destination versions).
如果我存储了这两个Blob的内容:
If I store the content of those two blobs:
C:\Users\VonC\prog\go\src\github.com\VonC\asciidocgo>
git cat-file -p 4f76d586459ec6ffc42257bb4c61d5422051cb10 > a
git cat-file -p 6124401794e7fee613f5a56593a0a8a059b2627a > b
(请注意,我如何将' 4f / $ c $ b> blob路径中的c>部分与路径的其余部分,以获得完整的sha1)
(Note how I concatenate the '4f/
' part of the blob path with the rest of the path in order to obtain the full sha1)
a $之间的差异c $ c>和
b
确实为我增加了我为同一文件添加的索引。
The diff between a
and b
does give me the additional bit I added to the index for that same file.
另一种(我认为更简单)的方法:
git fsck --lost-找到
。
悬挂的blob对象出现在.git / lost-found / other /
中,并且
您已经找到了所有的 cat-file -p-ed
。您在最后一个提交之前所做的前一个git add。
在我的案例中,只有一个出现:
You would indeed found all the previous git add you did before the final one which ended up committed.
In my case, only one showed up:
C:\Users\VonC\prog\go\src\github.com\VonC\asciidocgo\.git\lost-found\other>dir
Volume in drive C has no label.
Volume Serial Number is D866-48E1
Directory of C:\Users\VonC\prog\go\src\github.com\VonC\asciidocgo\.git\lost-found\other
25/01/2014 17:31 <DIR> .
25/01/2014 17:31 <DIR> ..
25/01/2014 17:31 16 873 4f76d586459ec6ffc42257bb4c61d5422051cb10