git学习笔记 二_第1页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、git学习笔记 二第五:对于对象的理解和实例分析 rootlocalhost /git/ rootlocalhost git object rootlocalhost object vim main.c hello wnayan! rootlocalhost object git hash-object main.c /计算main.c的哈希值 d32fe487dc38cbfc7fe051a5d6dbae01551d8dbd rootlocalhost object git init initializ empty git repository in /git/object/.git/ roo

2、tlocalhost object git a . 以下这个文件(blob)就是保存mia.c内容的文件 rootlocalhost object ll .git/objects/d3/ total 8 -r-r-r- 1 root root 30 nov 27 04:02 2fe487dc38cbfc7fe051a5d6dbae01551d8dbd rootlocalhost object git commit -m 1st commint master (root-commit) da97249 1st commint 1 s changed, 1 insertions(+), 0 del

3、etions(-) create mode 100644 main.c rootlocalhost object .git/objects/ -type f /列出文件夹下的一般文件 .git/objects/ae/eedc3b20507db9600f7f72431557fcf9303252 .git/objects/d3/2fe487dc38cbfc7fe051a5d6dbae01551d8dbd .git/objects/da/97249d3649b1770b5cec8fa515833ea596f26f rootlocalhost object git show d32f /查看blob的

4、内容,就是main.c的一样的内容 hello wnayan! rootlocalhost object git -file -t aeeedc /这三句是查看object的类型 ee rootlocalhost object git cat-file -t da97 commit rootlocalhost object git cat-file -t d32f blob 以上三种对象中保存文件的名字,blob保存文件的内容,这种结构有利于两个内容相同但是名字不同的文件的保存(tree保存两个名字,blob保存一份内容就可以了) rootlocalhost object git -tree

5、aeee /列出tree和blob的对应关系 100644 blob d32fe487dc38cbfc7fe051a5d6dbae01551d8dbd main.c rootlocalhost object git show -s -pretty=raw da97 /查看commit的内容,关系很明确 commit da97249d3649b1770b5cec8fa515833ea596f26f tree aeeedc3b20507db9600f7f72431557fcf9303252 author ethnicitybeta ethnicitybeta 1322337880 +0800 co

6、mmitter ethnicitybeta ethnicitybeta 1322337880 +0800 1st commint 第六:多层名目的实例 rootlocalhost / mkdir -p /git/wanyan rootlocalhost / cd /git/wanyan/ rootlocalhost wanyan cat readme just test! rootlocalhost wanyan cat lib/comment ilude rootlocalhost wanyan cat lib/include/main.c main rootlocalhost wanyan

7、 git init initialized empty git repository in /git/wanyan/.git/ rootlocalhost wanyan git add . rootlocalhost wanyan git commit -m 1st version master (root-commit) 206ecf2 1st version 3 files changed, 3 insertions(+), 0 deletions(-) create mode 100644 readme create mode 100644 lib/comment create mode

8、 100644 lib/include/main.c rootlocalhost wanyan find .git/objects/ -type f /查看生成的对象 .git/objects/03/e86fb4437c4153cec24aa4021dca582abc0558 .git/objects/56/2f7710be64f9309a9fe6aa529753953dbe7e47 .git/objects/20/6ecf269d0f540995d88d6be825fecb09b5d3eb .git/objects/8f/006adb88a619f20442a9eb3148cff31691e

9、af0 .git/objects/ba/2906d0666cf726c7eaadd2cd3db615dedf3a .git/objects/90/48a2fd8c21a70a2dffcf80c819eee2fb491a31 .git/objects/a1/a869c8c840478164594a788ae5ce38dc0ee6da rootlocalhost wanyan git cat-file -t 03e8 /可以通过这个依次查看对象的类型 tree rootlocalhost wanyan ll .git/head -rw-r-r- 1 root root 23 nov 27 04:2

10、3 .git/head /当前用法的commit是master rootlocalhost wanyan cat .git/head ref: refs/heads/master rootlocalhost wanyan cat .git/refs/heads/master 206ecf269d0f540995d88d6be825fecb09b5d3eb rootlocalhost wanyan git cat-file -t 206e commit 接下来就是修改随意的文件,来生成第多个版本的测试 rootlocalhost wanyan cd lib/ rootlocalhost lib

11、cat comment include change rootlocalhost wanyan git commit -a -m 2nd commit /这个指令是那两个指令的综合 master a7772df 2nd commit 1 files changed, 1 insertions(+), 0 deletions(-) rootlocalhost wanyan find .git/objects/ -type f /可以发觉对象显然的增强 .git/objects/5f/eaaa33f5f3b3bc5fae0b750b2a5ebdc74b0a27 .git/objects/03/e8

12、6fb4437c4153cec24aa4021dca582abc0558 .git/objects/56/2f7710be64f9309a9fe6aa529753953dbe7e47 .git/objects/57/440fcc9bc816076d418a2da304a2498b928bae .git/objects/20/6ecf269d0f540995d88d6be825fecb09b5d3eb .git/objects/8f/006adb88a619f20442a9eb3148cff31691eaf0 .git/objects/ba/2906d0666cf726c7eaadd2cd3db

13、615dedfdf3a .git/objects/90/48a2fd8c21a70a2dffcf80c819eee2fb491a31 .git/objects/a1/a869c8c840478164594a788ae5ce38dc0ee6da .git/objects/a7/772df6deb98005cf5ee21ae3ea863296677923 .git/objects/2c/f3d62adf771c30fa8062ce2c491d14486ea5ee 接下来这个步骤就是来打tag,tag分为轻量级的和全面包含的 首先是轻量级的tag这个tag虽然是对象,但是并不在对象名目里显示(obj

14、ect名目) rootlocalhost wanyan git tag v1.0 rootlocalhost wanyan ll .git/refs/tags/ total 8 -rw-r-r- 1 root root 41 nov 27 04:50 v1.0 rootlocalhost wanyan cat .git/refs/tags/v1.0 /可以发觉内容是commit呀 a7772df6deb98005cf5ee21ae3ea863296677923 rootlocalhost wanyan git cat-file -t a777 commit 然后是全面包含的tag,名目里显示(

15、object名目) rootlocalhost wanyan git tag -a stable1.0 -m 1st stable rootlocalhost wanyan find .git/objects/ -type f .git/objects/5f/eaaa33f5f3b3bc5fae0b750b2a5ebdc74b0a27 .git/objects/03/e86fb4437c4153cec24aa4021dca582abc0558 .git/objects/56/2f7710be64f9309a9fe6aa529753953dbe7e47 .git/objects/57/440fc

16、c9bc816076d418a2da304a2498b928bae .git/objects/20/6ecf269d0f540995d88d6be825fecb09b5d3eb .git/objects/8f/006adb88a619f20442a9eb3148cff31691eaf0 .git/objects/ba/2906d0666cf726c7eaadd2cd3db615dedfdf3a .git/objects/90/48a2fd8c21a70a2dffcf80c819eee2fb491a31 .git/objects/a1/a869c8c840478164594a788ae5ce38

17、dc0ee6da .git/objects/a7/772df6deb98005cf5ee21ae3ea863296677923 .git/objects/8a/26be084ddce5e8178ca91def21e0c8f7a0945e .git/objects/2c/f3d62adf771c30fa8062ce2c491d14486ea5ee rootlocalhost wanyan git cat-file -t 8a26 tag 接下来演示tag的用法 rootlocalhost wanyan vi readme /修改一下 just test! another hang! rootlo

18、calhost wanyan git commit -a -m 3rd commit master a08fc01 3rd commit 1 files changed, 1 insertions(+), 0 deletions(-) rootlocalhost wanyan cat readme just test! another hang! 下边的操作演示的是把tag那个状态(修改之前),那个打包出去 rootlocalhost wanyan git archive -foat=tar -prefix=wanyan/ v1.0 | g /tmp/wanyan.tar.gz rootlocalhost wanyan cd /tmp/ rootlocalhost tmp tar zxvf wanyan.tar.gz wany

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论