《Git Pro》第九章阅读笔记

1. 运行:

1 git log --pretty=oneline master

此时,会显示我在master分支下的所有commit,如下:

1 fe1bac37805a146b2d24d23c9ca8ad0a2434be5a (HEAD -> master) 5
2 4311cc7b89f190105030ea842bb69f9f4229e1fc fourth commit
3 f34f6e925b2b65a524964f8f880d5ebbbb367c11 version 3
4 338ac9d5d1fabe789cc363290a5926b2733a2e01 2
5 ba2de6a925665be7e5fb2edc3452257726c42b9c 1

2. 查看某次提交,比如查看最后一次提交:

1 git cat-file -p fe1bac37805a146b2d24d23c9ca8ad0a2434be5a

运行结果如下,可以看到其中包含了tree对象和parent 对象等信息:

1 tree 3bc5a771042cffe9473c442b0489a2546278abd7
2 parent 4311cc7b89f190105030ea842bb69f9f4229e1fc
3 author xshine_runningpig <[email protected]> 1560215247 +0800
4 committer xshine_runningpig <[email protected]> 1560215247 +0800
5 
6 5

3. 我们可以接着查看tree 3bc5a771042cffe9473c442b0489a2546278abd7指向的内容:

1 git cat-file -p 3bc5a771042cffe9473c442b0489a2546278abd7

可以看到,里面包含了blob对象,每个blob对象指向一个文件:

1 100644 blob 4070fb39ea97507b129eb207a96ad8a94f426165    test.txt
2 100644 blob 51750fd6f83d0470cdd9a61d2067d3a668ea8f6e    test_1

可以通过以下方式查看文件内容:

1 git cat-file -p 4070fb39ea97507b129eb207a96ad8a94f426165

内容就是此次提交时,test.txt中的内容,如下:

 1 version 2
 2 version 3
 3 fourth commit
 4 5
 5 5
 6 5
 7 5
 8 5
 9 5
10 5
11 5
12 5
13 5
14 5
15 5
# ============================================================ #
总结,Git 数据库的存储结构如下:

猜你喜欢

转载自www.cnblogs.com/hengguangliu/p/11100577.html
今日推荐