git init
echo 'I am foo' > foo.txt
git add foo.txt # this woould create a git commit object
echo ' I am foo2' > foo.txt
git add foo.txt # this would create another git commit object
git commit -m 'doe' # this would create two git
# objects: one commit object and one tree object
如何获得所有4个提交列表SHA1_HASH?所有提交列表SHA1_HASH
cd .git/objects
ls
(master)$ ls -al
total 0
drwxr-xr-x 8 nsingh staff 272 Mar 27 16:44 .
drwxr-xr-x 13 nsingh staff 442 Mar 27 16:44 ..
drwxr-xr-x 3 nsingh staff 102 Mar 27 16:44 37
drwxr-xr-x 3 nsingh staff 102 Mar 27 16:43 a2
drwxr-xr-x 3 nsingh staff 102 Mar 27 16:44 e1
drwxr-xr-x 3 nsingh staff 102 Mar 27 16:42 e6
drwxr-xr-x 2 nsingh staff 68 Mar 27 16:42 info
drwxr-xr-x 2 nsingh staff 68 Mar 27 16:42 pack
我可以通过查看文件在这里找到所有4个提交的列表,但必须有更好的方法。
你对创建四个提交对象也有点错误。所有的'git add'都会检查事物到索引中。当您运行'git commit'时,您只创建了一个提交。你几乎可以肯定不需要知道该提交树的SHA1是什么,但是如果你想知道,你可以使用'git log --pretty =%T'来看看它。 – Cascabel 2010-03-27 21:21:20
通过执行所有这些操作创建的对象是:提交(来自git commit),树(提交的树)和blob(foo.txt的内容)。第一个回声/添加对没有持续的影响,因为你用下一对覆盖了它。 – Cascabel 2010-03-27 21:22:53
要了解有关内部的更多信息,请尝试使用git社区书籍:http://book.git-scm.com/1_the_git_object_model.html或pro git:ttp://progit.org/book/ch9-2.html(在许多其他版本中) – Cascabel 2010-03-27 21:24:33