GitGit
🪡

Git

Last edited time
Apr 20, 2023 06:19 AM
Created
Feb 21, 2022 02:21 AM
Tags
 

概念

notion image
 
 

对象(object)

保存在.git/objects,
  1. 数据对象(blob object)
    1. 文件模式 100644 普通文件;100755 可执行文件;120000 符号链接;
  1. 树对象(tree object)
  1. 提交对象(commit object)
  1. 标签对象(tag object)
    1. 提交对象+日志+创建者+注释
 
数据对象的构成
content= ”xxxxx”

header = “blob #{content.length}\0”

store = content + content

sha1 = hex(store)
object = zip(store)

write("objects/sha1", object)
 

引用(refs)

保存在.git/refs,保存了一个树引用的sha1
 
.git/HEAD 是一个文件,指向了当前的最新提交

SubModule

git submodule add 

git submodule init   # 初始化贝蒂配置文件

git submodule update --recursive  # 抓取数据并检出父项目中列出的提交

git clone --recurse-submodules
 
 
 

reset & checkout

常见指令

git remote add

git add  精确滴将内容添加到下一次提交中

git commit  提交暂存区

git clone

git diff 工作区和上次提交的差异
git diff --cached 暂存区和上次提交的差异

底层指令

git init 初始化仓库

git hash-object 计算object的hash;-w 写入到数据库中

git cat-file 提取object的内容;-p 自动判断object类型;-t 查看对象类型

git update-index 更新暂存区;--add 将文件添加到暂存区;--cacheinfo 使用git数据库中的文件;

git write-tree 将暂存区内容写到一个树对象

git read-tree 将树对象添加到暂存区;--prefix 作为子树

git commit-tree 指定一个树对象创建一个提交对象;-p 引用上一个提交

git update-ref 更新引用

git symbolic-ref 查看或更新引用
 

Loading Comments...