1. 程式人生 > >Git/Github GitBash 2.2 .git.objects

Git/Github GitBash 2.2 .git.objects

pan ren bject 定位 每次 增加 inf not div

$ mkdir c
$ cd c
$ git init

//首次提交。

$ vim 1.txt
$ ls -alh .git/objects/
total 4.0K
drwxr-xr-x 1 desktop 197121 0 八月  8 17:00 ./
drwxr-xr-x 1 desktop 197121 0 八月  8 17:00 ../
drwxr-xr-x 1 desktop 197121 0 八月  8 17:00 info/
drwxr-xr-x 1 desktop 197121 0 八月  8 17:00 pack/
$ git add 1.txt
$ git commit -m .
$ ls -alh .git/objects/
total 
4.0K drwxr-xr-x 1 desktop 197121 0 八月 8 17:01 ./ drwxr-xr-x 1 desktop 197121 0 八月 8 17:01 ../ drwxr-xr-x 1 desktop 197121 0 八月 8 17:01 38/ drwxr-xr-x 1 desktop 197121 0 八月 8 17:01 81/ drwxr-xr-x 1 desktop 197121 0 八月 8 17:01 d0/ drwxr-xr-x 1 desktop 197121 0 八月 8 17:00 info/ drwxr-xr-x 1 desktop 197121 0 八月 8 17:00 pack/ $ find .git
/objects/ -type f .git/objects/38/fd29697b220f7e4ca15b044c3222eefe5afdc1 .git/objects/81/95bd571d304adf2632377d6dabc5880cfbdf36 .git/objects/d0/0491fd7e5bb6fa28c517a0bb32b8b506539d4d $ git cat-file -t 38fd tree $ git cat-file -t 8195 commit $ git cat-file -t d004 blob $ git show d004 1

//再次提交。

$ vim 1.txt
$ git add 1.txt
$ git commit 
-m . $ find .git/objects/ -type f .git/objects/11/91247b6d9a206f6ba3d8ac79e26d041dd86941 .git/objects/38/fd29697b220f7e4ca15b044c3222eefe5afdc1 .git/objects/4d/1356c6ae08b43a14779807b6be98554dce7d3c .git/objects/54/57b3462c78fd6d7590a15ad3be446a4fb5d1fd .git/objects/81/95bd571d304adf2632377d6dabc5880cfbdf36 .git/objects/d0/0491fd7e5bb6fa28c517a0bb32b8b506539d4d $ git cat-file -t 1191 blob $ git cat-file -t 4d13 commit $ git cat-file -t 5457 tree $ git show 1191 1 2

//顯然,每次提交,每個文件都增加一組(commit/tree/blob)。

//查看commit、tree、blob。

$ git show -s --pretty=raw 4d13
commit 4d1356c6ae08b43a14779807b6be98554dce7d3c
tree 5457b3462c78fd6d7590a15ad3be446a4fb5d1fd
parent 8195bd571d304adf2632377d6dabc5880cfbdf36
author yourname <[email protected]> 1533719156 +0800
committer yourname <[email protected]> 1533719156 +0800
$ git ls-tree 5457
100644 blob 1191247b6d9a206f6ba3d8ac79e26d041dd86941    1.txt
$ git show 1191
1
2

//tree格式:權限 節點類型 hash 節點名稱。

//commit後如果是穩定版本通常添加tag。
//git tag tagname //輕量 tag,不占對象。即.git/objects/不會增加數量。
//git tag -a tagname -m ‘note‘ //附註 tag,占對象。
//git tag tagname 4d13 //git tag tagname hash-object 為目標 commit 設置 tag。

//結論:
//commit,可以定位tree。
//tree,類似目錄,可以定位其下所有tree和blob。
//blob,指向文件數據,不帶名稱。
//tag,指向commit。

Git/Github GitBash 2.2 .git.objects