1.目录.Git
$ cd .git
查看目录
$ ls -al
total 56
drwxr-xr-x 8 root root 4096 Apr 13 18:08 .
drwxr-xr-x 4 root root 4096 Apr 13 18:03 ..
drwxr-xr-x 2 root root 4096 Apr 13 09:51 branches
-rw-r--r-- 1 root root 13 Apr 13 12:41 COMMIT_EDITMSG
-rw-r--r-- 1 root root 92 Apr 13 18:01 config
-rw-r--r-- 1 root root 73 Apr 13 09:51 description
-rw-r--r-- 1 root root 24 Apr 13 18:03 HEAD
drwxr-xr-x 2 root root 4096 Apr 13 09:51 hooks
-rw-r--r-- 1 root root 336 Apr 13 18:03 index
drwxr-xr-x 2 root root 4096 Apr 13 09:51 info
drwxr-xr-x 3 root root 4096 Apr 13 10:02 logs
drwxr-xr-x 19 root root 4096 Apr 13 12:41 objects
drwxr-xr-x 4 root root 4096 Apr 13 09:51 refs
-rw-r--r-- 1 root root 15 Apr 13 18:08 test.rb
2. 查看HEAD
$ cat HEAD
ref: refs/heads/subwork
HEAD文件中是一个引用,指向文件refs/heads/subwork(subwork是当前分支的名称), 查看文件内容
$ cat refs/heads/subwork
ea0c3d9b9f0d328dd71205ddfc273bb1d635b507
查看对象 “ea0c3d9b9f0d328dd”的类型。
$ git cat-file -t ea0c3d9b9f0d328dd
commit
“ea0c3d9b9f0d328dd”是一个commit。(注:字符串不必完整复制,能够唯一标识对象即可)
由此可见,HEAD指向了一个commit。
3.目录objects
$ cd objects
查看目录
$ ls -al
total 76
drwxr-xr-x 19 root root 4096 Apr 13 12:41 .
drwxr-xr-x 8 root root 4096 Apr 13 18:08 ..
drwxr-xr-x 2 root root 4096 Apr 13 12:41 0c
drwxr-xr-x 2 root root 4096 Apr 13 12:10 0f
drwxr-xr-x 2 root root 4096 Apr 13 10:02 14
drwxr-xr-x 2 root root 4096 Apr 13 12:10 1e
drwxr-xr-x 2 root root 4096 Apr 13 10:39 3a
drwxr-xr-x 2 root root 4096 Apr 13 10:39 51
drwxr-xr-x 2 root root 4096 Apr 13 10:02 9c
drwxr-xr-x 2 root root 4096 Apr 13 12:10 c4
drwxr-xr-x 2 root root 4096 Apr 13 10:39 d9
drwxr-xr-x 2 root root 4096 Apr 13 10:39 e0
drwxr-xr-x 2 root root 4096 Apr 13 10:39 e6
drwxr-xr-x 2 root root 4096 Apr 13 12:41 ea
drwxr-xr-x 2 root root 4096 Apr 13 10:02 eb
drwxr-xr-x 2 root root 4096 Apr 13 12:10 f7
drwxr-xr-x 2 root root 4096 Apr 13 12:41 fb
drwxr-xr-x 2 root root 4096 Apr 13 09:51 info
drwxr-xr-x 2 root root 4096 Apr 13 09:51 pack
进入目录3a。
$ cd 3a
查看目录。
$ ls -al
total 12
drwxr-xr-x 2 root root 4096 Apr 13 10:39 .
drwxr-xr-x 19 root root 4096 Apr 13 12:41 ..
-r--r--r-- 1 root root 122 Apr 13 10:39 d90f1713eac631f623473b59889ef820dc891f
将目录名称“3a”和文件名称“d90f1713eac631f623473b59889ef820dc891f”组合,查看类型。
$ git cat-file -t 3ad90f1713e
tree
查看内容。
$ git cat-file -p 3ad90f1713e
040000 tree e03c041f6c389a5ce5ff0161eba7a8ca31d23457 images
100644 blob d95f3ad14dee633a758d2e331151e950dd13e4ed index.html
100644 blob 14c0554362cd04881158d0900f6a73055f36c396 readme.txt