オブジェクトデータベースとは?
いいかげんgitのことをちゃんと知りたいというあなたへ(内部構造編)をご参照ください
.git/objectsの中身をさくっとみたい
.git/objects
にあるgitオブジェクトの
種類、サイズ、内容を表示します。
gitリポジトリに置いて実行してみてください
ls-git-obj.sh
#!/bin/shGITOBJ_DIR="./.git/objects"for path in${GITOBJ_DIR}/*;do
dir=`basename${path}`# ディレクトリ名が2文字のものの内容を表示if[${#dir}-eq 2 ];then
obj_name=`find ${GITOBJ_DIR}/${dir}-type f | xargs basename`echo'------------------------'echo${dir}${obj_name}echo'- type:'
git cat-file -t${dir}${obj_name}echo'- size:'
git cat-file -s${dir}${obj_name}echo'- contents:'
git cat-file -p${dir}${obj_name}fi
done
実行結果はこちら
$ ./ls-git-obj.sh
------------------------
20c8a040010b6ca65a4c9d75873da6b86aff7447
- type:
commit
- size:
178
- contents:
tree a760aa994bbdd615f7ecb442be6bab636e11eba6
author: atchy <atchy@example.com> 1610805112 +0900
committer atchy <atchy@example.com> 1610805112 1610805112 +0900
add aaa.txt
------------------------
72943a16fb2c8f38f9dde202b7a70ccc19c52f34
- type:
blob
- size:
4
- contents:
aaa
------------------------
a760aa994bbdd615f7ecb442be6bab636e11eba6
- type:
tree
- size:
35
- contents:
100644 blob 72943a16fb2c8f38f9dde202b7a70ccc19c52f34 aaa.txt
もうちょっときれいに表示できんもんかなあ