git设计哲学
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in /Users/lyc/Desktop/test/.git/
.git/
|--HEAD
|--config
|--description
|--hooks
| |--applypatch-msg.sample
| |--commit-msg.sample
| |--post-commit.sample
| |--post-receive.sample
| |--post-update.sample
| |--pre-applypatch.sample
| |--pre-commit.sample
| |--pre-rebase.sample
| |--prepare-commit-msg.sample
| |--update.sample
|--info
| |--exclude
|--objects
| |--info
| |--pack
|--refs
- description文件仅供GitWeb使用,不用关心它。
- config文件包含了项目特有的配置选项,如最常用的用户名和邮箱。
- info目录保存了一份不希望在 .gitignore 文件中管理的忽略模式 (ignored patterns) 的全局可执行文件。这个用得比较少,也不用太关心。
- hooks目录保存了客户端或服务端钩子脚本,一般我们都是用默认的,很少改,也不用太关心。
因此,我们需要重点关心另外四个重要的文件或目录:HEAD和index文件,objects和refs目录,因为它们是Git的核心:
- objects 目录存储所有数据内容。
- refs 目录存储指向数据 (分支) 的提交对象的指针。
- HEAD 文件指向当前分支。
- index 文件保存了暂存区域信息。
$ find .git/objects
.git/objects
.git/objects/info
.git/objects/pack
$ echo test1 > test1.txt
$ git add test1.txt
.git/
|--index
|--objects
| |--a5
| | |-- bce3fd2565d8f458555a0c6f42d0504a848bd5
$ find .git/objects
.git/objects
.git/objects/a5
.git/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5
.git/objects/info
.git/objects/pack
$ git hash-object test1.txt
a5bce3fd2565d8f458555a0c6f42d0504a848bd5
$ git cat-file -p a5bce3fd2565d8f458555a0c6f42d0504a848bd5
test1
$ git ls-files --stage
a5bce3fd2565d8f458555a0c6f42d0504a848bd5 test1.txt
$ git commit -m "first commit"
[master (root-commit) a3951d5] first commit
file changed, insertion(+)
create mode test1.txt
$ find .git/objects
.git/objects
.git/objects/a3
.git/objects/a3/951d57b1413275b171d967fa67fd90eecff648
.git/objects/a5
.git/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5
.git/objects/c0
.git/objects/c0/da834e42dcbf7b2b1c4a97925bef105d3863a3
.git/objects/info
.git/objects/pack
$ git cat-file -p a3951d57b1413275b171d967fa67fd90eecff648
tree c0da834e42dcbf7b2b1c4a97925bef105d3863a3
author lyc <yechenli2009@gmail.com> +
committer lyc <yechenli2009@gmail.com> + first commit $ git cat-file -p c0da834e42dcbf7b2b1c4a97925bef105d3863a3
blob a5bce3fd2565d8f458555a0c6f42d0504a848bd5 test1.txt
$ mkdir temp
$ cd temp/
$ echo "test2" > test2.txt
$ git add temp
$ git commit -am “second commit"
$ find .git/objects
.git/objects
.git/objects/
.git/objects//0cf8328022becee9aaa2577a8f84ea2b9f3827
.git/objects/
.git/objects//592c587f70cf6ec1b99bb382bec2ef92f83396
.git/objects/9e
.git/objects/9e/7b8054ac3ca530d8e69556dff5903cdcbdc4d3
.git/objects/a3
.git/objects/a3/951d57b1413275b171d967fa67fd90eecff648
.git/objects/a5
.git/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5
.git/objects/c0
.git/objects/c0/da834e42dcbf7b2b1c4a97925bef105d3863a3
.git/objects/d2
.git/objects/d2/5d2289339c751ff3f7e1ef1865a58c71d0f51c
.git/objects/info
.git/objects/pack
$ git log
commit d25d2289339c751ff3f7e1ef1865a58c71d0f51c
Author: lyc <yechenli2009@gmail.com>
Date: Sun Oct :: + second commit commit a3951d57b1413275b171d967fa67fd90eecff648
Author: lyc <yechenli2009@gmail.com>
Date: Sun Oct :: + first commit
.git/objects/d2/5d2289339c751ff3f7e1ef1865a58c71d0f51c
$ git cat-file -p d25d2289339c751ff3f7e1ef1865a58c71d0f51c
tree 35592c587f70cf6ec1b99bb382bec2ef92f83396
parent a3951d57b1413275b171d967fa67fd90eecff648
author lyc <yechenli2009@gmail.com> +
committer lyc <yechenli2009@gmail.com> + second commit
.git/objects//592c587f70cf6ec1b99bb382bec2ef92f83396
$ git cat-file -p 35592c587f70cf6ec1b99bb382bec2ef92f83396
tree 9e7b8054ac3ca530d8e69556dff5903cdcbdc4d3 temp
blob a5bce3fd2565d8f458555a0c6f42d0504a848bd5 test1.txt
.git/objects/9e/7b8054ac3ca530d8e69556dff5903cdcbdc4d3
$ git cat-file -p 9e7b8054ac3ca530d8e69556dff5903cdcbdc4d3
blob 180cf8328022becee9aaa2577a8f84ea2b9f3827 test2.txt
.git/objects//0cf8328022becee9aaa2577a8f84ea2b9f3827

git设计哲学的更多相关文章
- git database 数据库 平面文件 Git 同其他系统的重要区别 Git 只关心文件数据的整体是否发生变化,而大多数其他系统则只关心文件内容的具体差异 Git 的设计哲学
小结: 1.如果要浏览项目的历史更新摘要,Git 不用跑到外面的服务器上去取数据回来 2.注意 git clone 应指定版本,它复制的这个版本的全部历史信息: 各个分支 git init 数据库 ...
- 跟vczh看实例学编译原理——一:Tinymoe的设计哲学
自从<序>胡扯了快一个月之后,终于迎来了正片.之所以系列文章叫<看实例学编译原理>,是因为整个系列会通过带大家一步一步实现Tinymoe的过程,来介绍编译原理的一些知识点. 但 ...
- Python的设计哲学探究
在Python shell中输入import this就会在屏幕上打印出来Python的设计哲学,如下: In [25]: import this The Zen of Python, by Tim ...
- Java面向接口编程,低耦合高内聚的设计哲学
接口体现的是一种规范和实现分离的设计哲学,充分利用接口可以极大的降低程序中各个模块之间的耦合,提高系统的可维护性以及可扩展性. 因此,很多的软件架构设计理念都倡导"面向接口编程"而 ...
- Python的设计哲学
Beautiful is better than ugly. 优美胜于丑陋 Explicit is better than implicit. 明了胜于晦涩 Simple is better than ...
- 第八课:不一样的链表 linux链表设计哲学 5星级教程
这一课最后实现的链表,和普通链表不同,借鉴了linux内核链表的思想,这也是企业使用的链表. 基础介绍: 顺序表的思考 顺序表的最大问题是插入和删除需要移动大量的元素!如何解决?A:在线性表数据元素之 ...
- React的设计哲学 - 简单之美
React最初来自Facebook内部的广告系统项目,项目实施过程中前端开发遇到了巨大挑战,代码变得越来越臃肿且混乱不堪,难以维护.于是痛定思痛,他们决定抛开很多所谓的“最佳实践”,重新思考前端界面的 ...
- Python的设计哲学--zen of Python
Python的设计哲学--zen of Python Beautiful is better than ugly. 优美胜于丑陋 Explicit is better than ...
- 理解numpy中ndarray的内存布局和设计哲学
目录 ndarray是什么 ndarray的设计哲学 ndarray的内存布局 为什么可以这样设计 小结 参考 博客:博客园 | CSDN | blog 本文的主要目的在于理解numpy.ndarra ...
随机推荐
- BZOJ_2049_[Sdoi_2008]_Cave_洞穴勘测_(LCT/并查集)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=2049 给出一个森林,起始互不相连,现在有link和cut两种操作,问x,y是否在一棵树里. 分 ...
- linux下的X server:linux图形界面原理
linux下的X server:linux图形界面原理 Moblin Core是在Gnome Mobile的平台上建立.我以前玩Linux,提交的都和图像没有关系,连Xwindows都不用启动,开 ...
- c程序设计语言_习题8-6_利用malloc()函数,重新实现c语言的库函数calloc()
The standard library function calloc(n,size) returns a pointer to n objects of size size , with the ...
- 《C#并行编程高级教程》第5章 协调数据结构 笔记
本章介绍了一些轻量级的同步原语,其中有很大部分是.NET Framework 4才引入的. System.Threading.Barrier 用于一段程序分成多个阶段,每个阶段的开始都需要之前的阶段完 ...
- Chrome 控制台console的用法(学了之后对于调试js可是大大有用的哦)
大家都有用过各种类型的浏览器,每种浏览器都有自己的特色,本人拙见,在我用过的浏览器当中,我是最喜欢Chrome的,因为它对于调试脚本及前端设计调试都有它比其它浏览器有过之而无不及的地方.可能大家对co ...
- hunnu 小明的烦恼——找字符串
http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11544&courseid=0 小明的烦恼——找字符串 ...
- 分割函数和根据Id串返回名字
需求:函数传入一个字符串参数 例如 123-456 将这个字符串123-456拆成两个值 123 456,在通过两个值分别查出数据(例如 张三 李四),拼接成 张三-李四 --声明变量 ...
- Nhibernate Icreteria 分页查询
1.创建查询条件,条件为一个ICreterion的列表 /// /// 创建Criteria(不含order,因为获取总数的时候,为了性能考虑,不加order) /// ...
- OpenGL立方体在世界坐标系中_缩放_旋转_平移_顶点片源着色器_光照作用_棋盘纹理贴图
读取bmp等图片格式中的像素还有难度,就先用这个棋盘图象素来弄了 代码打错一个就一直First-chance exception ,貌似还有一个要用q或者Q才能成功退出,不知道缺少哪句,我用窗口红叉退 ...
- leetcode之Palindrome Partitioning
方法一:DFS递归,判断每一个是否为回文数 1,首先要有一个判断字符串是否是回文的函数.容易实现,字符串从两边同时往中间走,看字符是否相同; 2,深度优先搜索思想对字符串进行遍历.得到结果.例如,s ...