深入理解Git (五) - commit链的形成
2015-09-03 15:01
405 查看
我们新增一个文件比如second,内容为second_information,我们依次执行:
先生成blob对象。
# git hash-object -w second
abcdef
接下来更新cache。
# git update-index --add --cacheinfo abcdef second
接下来生成tree对象。
# git write-tree
efgh3d
接下来是生成commit链的重点了,我们要加上-p指出它的父亲commit节点是哪个。
# echo "second information" | git commit-tree efgh3d -p prcmit
ger9gd
最后我们更新HEAD的指向
# git update-ref refs/heads/master ger9gd
其实这条命令相当于,先读出HEAD的内容,比如refs/heads/master,然后更新其内容为新的commit,
大致类似于:
echo "ger9gd" > `cat HEAD`
另外update-ref时,还要更新reflog信息以便进行数据恢复,这个以后再说。好了,我们现在可以git log查看历史commit了。
原文:http://blog.csdn.net/hongchangfirst/article/details/45334833
作者:hongchangfirst
hongchangfirst的主页:http://blog.csdn.net/hongchangfirst
先生成blob对象。
# git hash-object -w second
abcdef
接下来更新cache。
# git update-index --add --cacheinfo abcdef second
接下来生成tree对象。
# git write-tree
efgh3d
接下来是生成commit链的重点了,我们要加上-p指出它的父亲commit节点是哪个。
# echo "second information" | git commit-tree efgh3d -p prcmit
ger9gd
最后我们更新HEAD的指向
# git update-ref refs/heads/master ger9gd
其实这条命令相当于,先读出HEAD的内容,比如refs/heads/master,然后更新其内容为新的commit,
大致类似于:
echo "ger9gd" > `cat HEAD`
另外update-ref时,还要更新reflog信息以便进行数据恢复,这个以后再说。好了,我们现在可以git log查看历史commit了。
原文:http://blog.csdn.net/hongchangfirst/article/details/45334833
作者:hongchangfirst
hongchangfirst的主页:http://blog.csdn.net/hongchangfirst
相关文章推荐
- hdu4389 Xmod f(x) 数位DP
- html 文本标签
- 1058. A+B in Hogwarts (20) -- 数据范围问题
- 一道关于笔试的多线程题目
- 后台开发面试准备2:linux共享内存
- python2.7学习笔记(8) ——模块
- 绘图与动画之使用自定义属性与颜色渐变实现色带加载动画
- TCP/IP、Http等各层协议汇总表
- ios开发 UI阶段第八周
- android性能优化之SparseArray
- LTE学习:LTE系统中RB、RBG、CCE、REG分别是如何定义的
- NOIP2014联合权值
- 一名程序员的自我修养
- JavaScript-概述
- scanf和gets的几个区别
- Android drawable中xml标签属性
- 小议:SharePoint 2013如何创建与Web Application不同的Host Header Site Collection?
- 为什么网页背景图片都切开
- UINavigationController
- java_servlet字符过滤器filter