我理解git使用内容来处理文件内容,内容哈希用作目标文件名.然后git存储原始文件名在哪里?例如,当git checkout一个提交时,它如何从对象中获取文件名?git如何处理重命名?
谢谢
Git将提交存储为对象,您可以查看这些对象.例如,获取提交ID,您可以以原始文件形式查看它.
$ git cat-file -p 3d911c37dc7cc6d50af9cbc66aa36084158308f5
tree 487660899e53bef8b15d3e1692172f689ed965c5
parent aa3b68973e845b7a900ab164603f154c8a1ba1c5
author Dan Lowe 1483760015 -0500
committer Dan Lowe 1483760015 -0500
Update line number settings in vim for 7.4+
如您所见,提交的一部分是树对象.这是存储文件路径的位置.您还可以使用与上面相同的机制检查该对象,并且您将看到路径名称.这是上面提交中提到的树对象:
$ git cat-file -p 487660899e53bef8b15d3e1692172f689ed965c5
100644 blob fc99cb33777f31c151278740abae2a9e6a2f7356 .gitignore
100644 blob b727328afdaa7ade85a89c1c1bde3c1bad0524a9 README.md
040000 tree affb2dde9693434395cc5c427f53c50b5f25f95d bash
100644 blob 95c2c67c1a3cf22a8ae9bb6c801a51e0fb0723f2 bash_profile
100644 blob 5083122a9ce0d6b8cc5219cfe25f3f14087be00b bashrc
100644 blob 2edff3b0b1c912cd020619dcb8e70284328d5457 colordiffrc
100644 blob 58e72f6937ba6c3e9119328eeacccd0e141dbc53 cvsrc
100644 blob 9e7a88c4db0d022d174a7dcb9e712999d2c256f1 emacs
100644 blob fb85e6f14ec59c76a74e9cd7119f060808ab64f6 gitconfig
100644 blob 6b5a544e8cacb49a419f062aa4130edbec057af3 gitignore
100644 blob 2a1154da1b962dcdd9fd8e56c691315e3145b0ef hgrc
100644 blob ef8a9c0034a129853b3e128efac02f86f0ecf0dc inputrc
100755 blob 96b2cac25e910ff031921003334eb0a35ea64e3f install.pl
100644 blob 83bce8d003a7620f6c35f489651da254c6376512 ircrc
040000 tree dafeb513b528067139128480b1223a41d6fa3f92 lib
100644 blob 8bd4ed3e6de8e10543f202816d8414f4ed4ebcc2 perldb
100644 blob 3c4f18565031942b8c85428276c81bb7238a1983 perltidyrc
100644 blob 5fe87e63c55725a70891510d9940eccd8bb5f734 pgclirc
100644 blob 7c400b451eefcbff3057146d430be92b2f86e09c pryrc
100644 blob 753e436e761394641b6eb7ac08a26c61ae56e04c psqlrc
100644 blob b5eb20d055a89f0b680c1a60fbe9325d018ef1d6 screenrc
040000 tree eaa4bfe31780f6ae866181d29ddac3f350d4130f scripts
100644 blob 1a57ec4dd3ecb92e0139af37563e1b3402a49e62 tcshrc
040000 tree cc106ffdee9efcfb22c1af9660a342853a47bee5 terminfo
100644 blob cf64f721be160dcc0f09852ee928d27836e13f26 tmux.conf
040000 tree 6ba373cc4a269d51b07b9b4c22816c8dcc140986 vim
100644 blob 109608f97d29d495ced16f4b507cf05981241b8d vimrc
100644 blob bb8b48639b198fe4af3648886e40d8a8f19611f7 zlogin
100644 blob f291f18aae6be481b5ac58ec9833e8e67f6e63b5 zlogout
100644 blob c976c7f3ff67b911de3eb49672f40b4652f5118e zshenv
100644 blob 9b2f38ad7c0941e928d6d33b6abb58addb29f179 zshrc
这里大多数对象都是blob(文件).但你可以看到这里还有其他树木.您可以查看这些内容并查看其他更改内容.例如,上面有一个用于"bash"的树对象.
$ git cat-file -p affb2dde9693434395cc5c427f53c50b5f25f95d
100644 blob dfc93b18e48ce6a75688b612c6f022f94b764029 alias.sh
100644 blob 83841c91abe242a7a400bd8cdc90eb2f8e827feb completion.sh
100644 blob d141fafeef4f89d015ccd2616f9b653167e957e8 config.sh
100644 blob f61e217197de7a8d7e069e06067184849bc4ebb2 environment.sh
100644 blob 9c5c706dc2bb80a672b60c3c769e78883533401d function.sh
100644 blob c6dc2b8963a6c4e4a53df41f0ad7e354e5da8fd7 library.sh
100644 blob c29db806365b731e60c2ad161a7d3a89d32def34 mac.sh
100644 blob 94f5b6f2a8e792c0cd3e502085418c91bd02aefe non-root.sh
100644 blob d7c41e0a5fb7f4456a70dac069ea5cb568de4faf project-mgmt.sh
因此,这些要提到bash/alias.sh
,bash/completion.sh
等.
您可以在git文档中阅读有关树的更多信息.