HAED 文件包含对 git分支 的操作记录,如
- vi HEAD
- # 99a10c283c33beed7f31c210a6c8b411d2a31085 5daf6094ea2cc60d17e947c0435096a4bdafe82d yeshou <yeshou@xxx.com> 1535082919 +0800 commit: rm files
- # 5daf6094ea2cc60d17e947c0435096a4bdafe82d b8e02a5f9c2bf44342d15f5ea1e60ffd9434765a yeshou <yeshou@xxx.com> 1535087285 +0800 checkout: moving from test to master
- # 先是删除文件后提交了次,再是由test检出到master
refs 文件夹包含 heads 文件夹,remote文件夹。heads 记录本地相关的各 git分支 操作记录,remote 记录远程仓库相关的各 git分支 操作记录
- cd heads
- ls
- # master master分支操作记录
- # test test分支操作记录
-
- cd remote/origin
- ls
- # master 远程master分支操作记录
- # test 远程test分支操作记录
HEAD 文件指示当前被检出(所在)的分支,如当前在test分支,文件内容则为ref: refs/heads/test。
index 文件是当前版本的文件索引,包含生成当前树(唯一确定的)对象的所虚信息,可用于快速比对工作树和其他提交树对象的差异(各commit和HEAD之间的diff),可用于存储单文件的多个版本以有效的解决合并冲突。可使用git ls-files 查看index文件内容。如:
- git commit 的一次提交从index中的信息生成tree对象,将其存储在对象数据库中,并与本次新的commit做关联,产生本次commit的tree信息(下面的objects介绍中会提到commit和tree)。
refs/ (references) 文件夹存储指向数据(分支)的提交对象指针;其中 heads 文件夹记录内部文件对应名称的分支的提交对象;tags记录内部文件对应名称的标签的提交对象;remotes记录内部文件对应名称的远程仓库分支的提交对象;
举个例子:
- cat .git/refs/heads/master
- # ce1fed3fdbaf12e816e3028055f9feee57b33b45 当前master的提交记录
- git checkout -b test # 检出一个新分支
- find .git
- # 多了个 .git/refs/heads/test 文件
- git log
-
- # commit 63a85dcbc6978f2d43996f5bebc38993c2afadaa (HEAD -> test)
- # Author: yeshou <yeshou@xxx.com>
- # Date: Sat Aug 25 13:57:26 2018 +0800
- #
- # branch test : edit test : add line : write d
-
- # commit ce1fed3fdbaf12e816e3028055f9feee57b33b45 (master)
- # Author: yeshou <yeshou@xxx.com>
- # Date: Sat Aug 25 12:40:35 2018 +0800
- #
- # edit test : add line : write c
-
- cat .git/refs/heads/test
- # 63a85dcbc6978f2d43996f5bebc38993c2afadaa 当前test的最近提交记录
- cat .git/refs/heads/master
- # ce1fed3fdbaf12e816e3028055f9feee57b33b45 依然是当前master的最近提交记录
另两者亦然。
objects/ 文件夹用以存储git仓库中的所有数据内容。
一步步来…
(编辑:源码网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|