探秘.git目录
在此之前,提一下gitk命令,gitk会调出一个git图形界面工具,不具体赘述,可以自己查看。
HEAD文件
首先打开.git目录
$ cd .git/ $ ls -la total 56 drwxr-xr-x 15 jamme staff 480 5 14 22:49 . drwxr-xr-x 5 jamme staff 160 4 29 22:10 .. -rw-r--r-- 1 jamme staff 9 4 29 22:12 COMMIT_EDITMSG -rw-r--r-- 1 jamme staff 21 4 29 22:08 HEAD -rw-r--r-- 1 jamme staff 41 4 29 21:31 ORIG_HEAD drwxr-xr-x 2 jamme staff 64 4 28 22:08 branches -rw-r--r-- 1 jamme staff 191 4 28 22:10 config -rw-r--r-- 1 jamme staff 73 4 28 22:08 description -rw-r--r-- 1 jamme staff 375 5 14 22:49 gitk.cache drwxr-xr-x 13 jamme staff 416 4 28 22:08 hooks -rw-r--r-- 1 jamme staff 201 4 29 22:12 index drwxr-xr-x 3 jamme staff 96 4 28 22:08 info drwxr-xr-x 4 jamme staff 128 4 28 22:19 logs drwxr-xr-x 20 jamme staff 640 5 14 22:53 objects drwxr-xr-x 4 jamme staff 128 4 28 22:08 refs $ cat HEAD ref: refs/heads/temp $ git branch -av master 4d2bddd rename * temp 543c5d8 add test $ cd .. $ git checkout master Switched to branch 'master' $ cat .git/HEAD ref: refs/heads/master
|
config文件
$ cat .git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [user] name = xxx email = xxx@xxx.com $ vi .git/config $ git config --local --list core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true core.ignorecase=true core.precomposeunicode=true user.name=jamme user.email=xxx@xxx.com $ git config --local user.name jamme $ git config --local user.name 'xxx' $ git config --local user.name xxx $ cat .git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [user] name = xxx email = xxx@xxx.com
|
refs目录
$ cd .git/refs/ $ ls -la total 0 drwxr-xr-x 4 jamme staff 128 4 28 22:08 . drwxr-xr-x 15 jamme staff 480 5 14 23:14 .. drwxr-xr-x 4 jamme staff 128 4 29 22:12 heads drwxr-xr-x 3 jamme staff 96 5 14 22:53 tags $ cd heads/ $ ls -la total 16 drwxr-xr-x 4 jamme staff 128 4 29 22:12 . drwxr-xr-x 4 jamme staff 128 4 28 22:08 .. -rw-r--r-- 1 jamme staff 41 4 29 21:36 master -rw-r--r-- 1 jamme staff 41 4 29 22:12 temp $ cat master 4d2bdddf4098e40ce57fdaf04bb862f7bea04918 $ git cat-file -t 4d2bdddf4098e40ce57fda commit $ git branch -av * master 4d2bddd rename temp 543c5d8 add test $ cat temp 543c5d84e8b5f2996e1a40745262f39df95eebaf $ cd ../tags/ $ ls -la total 8 drwxr-xr-x 3 jamme staff 96 5 14 22:53 . drwxr-xr-x 4 jamme staff 128 4 28 22:08 .. -rw-r--r-- 1 jamme staff 41 5 14 22:53 test $ cat test 0eaa4776504680c4df3677d5d66a7f4b8f0c5ffe $ git cat-file -t 0eaa47765 tag $ git cat-file -p 0eaa47765 object d34df54beffb33cf6e4f4e97d0f0e24f2b676d51 type commit tag test tagger xxx <xxx@xxx.com> 1557845639 +0800
tag test $ git cat-file -t d34df5 commit
|
objects目录
$ cd objects/ $ ls -la total 0 drwxr-xr-x 20 jamme staff 640 5 14 22:53 . drwxr-xr-x 15 jamme staff 480 5 14 23:14 .. drwxr-xr-x 3 jamme staff 96 5 14 22:53 0e drwxr-xr-x 3 jamme staff 96 4 28 22:19 33 drwxr-xr-x 3 jamme staff 96 4 29 21:36 4d drwxr-xr-x 3 jamme staff 96 4 29 22:12 54 drwxr-xr-x 3 jamme staff 96 4 29 20:48 5d drwxr-xr-x 3 jamme staff 96 4 29 20:48 64 drwxr-xr-x 3 jamme staff 96 4 29 21:02 85 drwxr-xr-x 3 jamme staff 96 4 29 20:47 8b drwxr-xr-x 3 jamme staff 96 4 29 20:47 90 drwxr-xr-x 3 jamme staff 96 4 29 22:12 9c drwxr-xr-x 3 jamme staff 96 4 29 21:36 9f drwxr-xr-x 3 jamme staff 96 4 29 22:12 c9 drwxr-xr-x 3 jamme staff 96 4 29 21:02 d3 drwxr-xr-x 3 jamme staff 96 4 29 21:05 dd drwxr-xr-x 3 jamme staff 96 4 28 22:17 e6 drwxr-xr-x 3 jamme staff 96 4 28 22:19 e8 drwxr-xr-x 2 jamme staff 64 4 28 22:08 info drwxr-xr-x 2 jamme staff 64 4 28 22:08 pack $ cd e8/ $ ls -la total 8 drwxr-xr-x 3 jamme staff 96 4 28 22:19 . drwxr-xr-x 20 jamme staff 640 5 14 22:53 .. -r--r--r-- 1 jamme staff 51 4 28 22:19 0ad49ace82167de62e498622d70377d913c79e $ git cat-file -t e80ad49ace82167de62e498622d70377d913c79e tree $ git cat-file -p e80ad49ace82167de62e498622d70377d913c79e 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 readme $ git cat-file -t e69de29bb2d1d64 blob $ git cat-file -p e69de29bb2d1d64 sssssss
|
git中有一个神奇的地方,只要任何文件的文件内容相同,那么在git的眼里就是一个唯一的blob。