您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
11 小练习:数一数tree的个数
发布时间:2020-07-11 10:42:43编辑:雪饮阅读()
暂存区也会存储于objects中
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2
$ git init
Initialized empty Git repository in C:/Users/xy/Desktop/web/web2/.git/
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ mkdir doc
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ echo "readme" > doc/readme
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git add doc
warning: LF will be replaced by CRLF in doc/readme.
The file will have its original line endings in your working directory
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: doc/readme
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ find .git/objects -type f
.git/objects/81/78c76d627cade75005b40711b92f4177bc6cfc
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -t 8178c76d627cade750
blob
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -p 8178c76d627cade750
readme
提交后objects
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git commit -m 'add readme'
[master (root-commit) 8d69518] add readme
1 file changed, 1 insertion(+)
create mode 100644 doc/readme
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ find .git/objects -type f
.git/objects/20/3809dc435dd4e78d203cbf766a17581d77b2fa
.git/objects/68/774cf7f8ce4b4d661222d4560ad4caf2ea9112
.git/objects/81/78c76d627cade75005b40711b92f4177bc6cfc
.git/objects/8d/69518fc3ba3ee5a60d90ed7f61d020d59cde0d
发现readme文件竟然是tree
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -t 203809dc4
tree
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -p 203809dc4
100644 blob 8178c76d627cade75005b40711b92f4177bc6cfc readme
Doc为tree是因为它本来就是目录
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -t 68774cf7f8ce
tree
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -p 68774cf7f8ce
040000 tree 203809dc435dd4e78d203cbf766a17581d77b2fa doc
Readme这个tree下面的readme才是最终的blob
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -t 8178c76d627
blob
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -p 8178c76d627
readme
commit就是commit,其包含tree为doc
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -t 8d69518fc3ba3ee5a60d
commit
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web2 (master)
$ git cat-file -p 8d69518fc3ba3ee5a60d
tree 68774cf7f8ce4b4d661222d4560ad4caf2ea9112
author 雪饮 <1509272975@qq.com> 1594434480 +0800
committer 雪饮 <1509272975@qq.com> 1594434480 +0800
add readme
总结
关键字词:git,tree,blob,commit