.git目录结构(部分)

执行 git init会在当前目录生成.git

或者 git clone 将远程库下载本地,远程库名称/.git

git init生成的 .git目录是一个空的Git存储库或重新初始化现有存储库

git clone 的.git目录会包含写之前的操作的一些信息

无论git init 还是 git clone后续的操作对相应文件的读写是一样的。

以下 是以 git init来阐述的

 

HEAD

- 本地仓库的当前引用

- 文件内容格式:refs/heads/<branchName> // 默认分支master, 执行git init自动创建本地master分支

- cat .git/HEAD

- ref: refs/heads/master

- git checkout dev

- ref: refs/heads/dev


refs/heads/branchName

- 本地仓库的对应分支最近一次commit或者pull后的logID //push后将同步远程

- (commit pull)

两者关系类似
- HEAD -> refs/heads/branchName -> last logID


refs/remotes/origin(repertoryName)/branchName
- (push pull fetch)
- 远程仓库对应分支最近一次push/pull/fetch后的logID

 

logs/refs/heads/branchName

- 本地仓库对应分支下操作所有记录
- (commit pull)
- cat logs/refs/heads/branchName

- 0000000000000000000000000000000000000000 6ad1520b3f9274a84f207e2b85eb8ef17c8b48b7 author info 1555031929 +0800 initial pull
- 6ad1520b3f9274a84f207e2b85eb8ef17c8b48b7 49fb248c9691fccb330457f3e9b5d18d55db26ae author info 1555032894 +0800 pull origin master: Fast-forward
- 49fb248c9691fccb330457f3e9b5d18d55db26ae 021387b81bf84b989a7381b74bcb292dddc7ccf4 author info 1555035120 +0800 commit: test1-master 初始化c.txt

 

logs/refs/remotes/origin(repertoryName)/branchName

- 远程仓库对应分支所有操作
- (pull push fetch)
- 0000000000000000000000000000000000000000 6ad1520b3f9274a84f207e2b85eb8ef17c8b48b7 author info 1555031929 +0800 pull origin master: storing head
- 6ad1520b3f9274a84f207e2b85eb8ef17c8b48b7 49fb248c9691fccb330457f3e9b5d18d55db26ae author info 1555032894 +0800 pull origin master: fast-forward

 

logs/HEAD

- 结构同logs/refs/heads/branchName

- (commit pull)

- 本地仓库所有分支所有操作记录,包含创建和切换分支


COMMIT_EDITMSG

- 本地最后一个提交的信息


objects/

- commitID 前两位为文件夹,目录下有一个commitID去除前两位命名的文件,可能是每次提交快照(待确认)

 

FETCH_HEAD
- 从远程库更新后,记录远程库最近一次push上去的logID

- (pull fetch)

- git checkout master

- git pull origin master

- cat FETCH_HEAD

- a2eea6bb95b1b4cdc8fdf9ce9318a2ece4df3fff branch 'master' of https://github.com/xxx/xxx

 

ORIG_HEAD

- 可理解成 ORIGIN_HEAD

- 从远程库更新后对应分支本地最近一次commit的logID

 

index

- add commit会写入数据(其他待定)

以上 仅供参考!

参考博客:https://blog.csdn.net/songyuequan/article/details/82933745

posted @ 2019-04-12 17:33  昵称还没想好  阅读(962)  评论(0)    收藏  举报