标签:
$ mkdir test $ cd test $ git init Initialized empty Git repository in /Users/lyc/Desktop/test/.git/
.git/ |--HEAD |--config |--description |--hooks | |--applypatch-msg.sample | |--commit-msg.sample | |--post-commit.sample | |--post-receive.sample | |--post-update.sample | |--pre-applypatch.sample | |--pre-commit.sample | |--pre-rebase.sample | |--prepare-commit-msg.sample | |--update.sample |--info | |--exclude |--objects | |--info | |--pack |--refs
因此,我们需要重点关心另外四个重要的文件或目录:HEAD和index文件,objects和refs目录,因为它们是Git的核心:
$ find .git/objects .git/objects .git/objects/info .git/objects/pack
$ echo test1 > test1.txt $ git add test1.txt
.git/ |--index |--objects | |--a5 | | |-- bce3fd2565d8f458555a0c6f42d0504a848bd5
$ find .git/objects .git/objects .git/objects/a5 .git/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 .git/objects/info .git/objects/pack
$ git hash-object test1.txt a5bce3fd2565d8f458555a0c6f42d0504a848bd5
$ git cat-file -p a5bce3fd2565d8f458555a0c6f42d0504a848bd5 test1
$ git ls-files --stage 100644 a5bce3fd2565d8f458555a0c6f42d0504a848bd5 0 test1.txt
$ git commit -m "first commit" [master (root-commit) a3951d5] first commit 1 file changed, 1 insertion(+) create mode 100644 test1.txt
$ find .git/objects .git/objects .git/objects/a3 .git/objects/a3/951d57b1413275b171d967fa67fd90eecff648 .git/objects/a5 .git/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 .git/objects/c0 .git/objects/c0/da834e42dcbf7b2b1c4a97925bef105d3863a3 .git/objects/info .git/objects/pack
$ git cat-file -p a3951d57b1413275b171d967fa67fd90eecff648 tree c0da834e42dcbf7b2b1c4a97925bef105d3863a3 author lyc <yechenli2009@gmail.com> 1444534714 +0800 committer lyc <yechenli2009@gmail.com> 1444534714 +0800 first commit $ git cat-file -p c0da834e42dcbf7b2b1c4a97925bef105d3863a3 100644 blob a5bce3fd2565d8f458555a0c6f42d0504a848bd5 test1.txt
$ mkdir temp $ cd temp/ $ echo "test2" > test2.txt $ git add temp $ git commit -am “second commit"
$ find .git/objects .git/objects .git/objects/18 .git/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 .git/objects/35 .git/objects/35/592c587f70cf6ec1b99bb382bec2ef92f83396 .git/objects/9e .git/objects/9e/7b8054ac3ca530d8e69556dff5903cdcbdc4d3 .git/objects/a3 .git/objects/a3/951d57b1413275b171d967fa67fd90eecff648 .git/objects/a5 .git/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 .git/objects/c0 .git/objects/c0/da834e42dcbf7b2b1c4a97925bef105d3863a3 .git/objects/d2 .git/objects/d2/5d2289339c751ff3f7e1ef1865a58c71d0f51c .git/objects/info .git/objects/pack
$ git log commit d25d2289339c751ff3f7e1ef1865a58c71d0f51c Author: lyc <yechenli2009@gmail.com> Date: Sun Oct 11 13:54:00 2015 +0800 second commit commit a3951d57b1413275b171d967fa67fd90eecff648 Author: lyc <yechenli2009@gmail.com> Date: Sun Oct 11 11:38:34 2015 +0800 first commit
.git/objects/d2/5d2289339c751ff3f7e1ef1865a58c71d0f51c
$ git cat-file -p d25d2289339c751ff3f7e1ef1865a58c71d0f51c tree 35592c587f70cf6ec1b99bb382bec2ef92f83396 parent a3951d57b1413275b171d967fa67fd90eecff648 author lyc <yechenli2009@gmail.com> 1444542840 +0800 committer lyc <yechenli2009@gmail.com> 1444542840 +0800 second commit
.git/objects/35/592c587f70cf6ec1b99bb382bec2ef92f83396
$ git cat-file -p 35592c587f70cf6ec1b99bb382bec2ef92f83396 040000 tree 9e7b8054ac3ca530d8e69556dff5903cdcbdc4d3 temp 100644 blob a5bce3fd2565d8f458555a0c6f42d0504a848bd5 test1.txt
.git/objects/9e/7b8054ac3ca530d8e69556dff5903cdcbdc4d3
$ git cat-file -p 9e7b8054ac3ca530d8e69556dff5903cdcbdc4d3 100644 blob 180cf8328022becee9aaa2577a8f84ea2b9f3827 test2.txt
.git/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827
标签:
原文地址:http://www.cnblogs.com/lycokcc/p/4869288.html