您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
10 commit、tree和blob三个对...
发布时间:2020-07-05 15:53:19编辑:雪饮阅读()
commit,tree与blob的对应关系
结语:一个commit对应一棵树,一棵树对应一个或多个blob、一个或多个树
首先我们先按照这个结语创建一次提交。
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git branch
* branch2
branch3
master
temp
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ mkdir branch2dir1
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ vi branch2dir1/1.txt
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ mkdir branch2dir1/dir1
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ vi branch2dir1/dir1/2.txt
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git add ./*
warning: LF will be replaced by CRLF in branch2dir1/1.txt.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in branch2dir1/dir1/2.txt.
The file will have its original line endings in your working directory
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git commit -m 'branch2 commit 20200705'
[branch2 795e4fc] branch2 commit 20200705
2 files changed, 2 insertions(+)
create mode 100644 branch2dir1/1.txt
create mode 100644 branch2dir1/dir1/2.txt
接下来我们查看commit
$ git log -n1
commit 795e4fcb73551a8f172af6e421d136da3738b133 (HEAD -> branch2)
Author: xy220807 <1509272975@qq.com>
Date: Sun Jul 5 15:34:12 2020 +0800
branch2 commit 20200705
$ git cat-file -p 795e4fcb73551a8f172af6e421d136da3738b133
tree 6f93f78f11d3aea79980cd79fea5b063a343b038
parent 48142d39abcd7f51c16d4eb50127445af496d056
author xy220807 <1509272975@qq.com> 1593934452 +0800
committer xy220807 <1509272975@qq.com> 1593934452 +0800
branch2 commit 20200705
发现这里commit中包含了一个tree,我们再来看看这个tree
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git cat-file -p 6f93f78f11d3aea79980cd79fea5b063a343b038
100644 blob c4192631f25b34d77a7f159aa0da0e3ae99c4ef4 _config.yml
040000 tree 3f92d45129b5ac8f17731ab4c5f0ace608272cf4 branch2dir1
040000 tree e0943aac663aabb3a09e7560e4dd92741ecbf29f css
100644 blob df36fcfb72584e00488330b560ebcf34a41c64c2 favicon.ico
040000 tree 0e042c19d436acb7c30759643516eec6c862a0b1 img
100644 blob 1f380b4ad55d1f95446ab3602a6a101cdfdae5f7 index.html
100644 blob c41d1d595f36a59051be8a808bd1dc425ebd0842 index.md
040000 tree fb73adb7a27517731051d98818fa90c721219f33 js
100644 blob 23cc39a711d81ad1118dfb62ba0d3ef66b0003b9 manifest.json
100644 blob 6f1beaf83959c7f0d0fa28de3d01db12710c7f9a precache-manifest.e8e73119b8fa65dc25182e8e58562d0c.js
100644 blob eb0536286f3081c6c0646817037faf5446e3547d robots.txt
100644 blob 76c9b64ced0fdcf7e40978e8bd3f8b296df96035 service-worker.js
我们发现这个tree又包含又blob和tree,那么我们再来看看blob
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git cat-file -p 23cc39a711d81ad1118dfb62ba0d3ef66b0003b9
{"name":"pwa3","short_name":"pwa3","theme_color":"#4DBA87","icons":[{"src":"./img/icons/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"./img/icons/android-chrome-512x512.png","sizes":"512x512","type":"image/png"},{"src":"./img/icons/android-chrome-maskable-192x192.png","sizes":"192x192","type":"image/png","purpose":"maskable"},{"src":"./img/icons/android-chrome-maskable-512x512.png","sizes":"512x512","type":"image/png","purpose":"maskable"}],"start_url":".","display":"standalone","background_color":"#000000"}
会发现这里的blob就是直接的文件内容了,那么我们再来看看这里的tree
没有错,这里的tree又是一个目录
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git cat-file -p fb73adb7a27517731051d98818fa90c721219f33
100644 blob ed8f593470af4bbe2ae386985dab57c8cb2b5efb app.f73030f9.js
100644 blob e19aed9552148b760f0d9c02844f7ec36e38a784 app.f73030f9.js.map
100644 blob 32c9b76efe5d49620f2ccf42a9be42dda0b612ba chunk-vendors.0396140b.js
100644 blob 8eea8e0372ce00a42304689d52c5780c2c288acb chunk-vendors.0396140b.js.map
这就是commit、tree、blob这三者的关系
关键字词:git,commit,tree,blob
上一篇:09 探密.git目录