Git 学习笔记


git中的文件内容(blob)均是以hash值来保存的,每个内容将生成一个object.同样的内容则会生成相同的hash值

cat-file -t 命令可以让 Git 返回任何对象的类型:

$ git cat-file -t 1f7a7a472abf3dd9643fd615f6da379c4acb3e3ablo

git add

修改过后的文件要以add命令来推入修改并用git status来查看文件状态

现在我们来修改一下1.py而未经add来看看状态有什么改变

➜  test git:(master) echo test > 1.py

➜  test git:(master) git status

On branch master


No commits yet


Changes to be committed:

  (use "git rm --cached <file>..." to unstage)


new file:   1.py

new file:   1.txt


Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git checkout -- <file>..." to discard changes in working directory)


modified:   1.py


Untracked files:

  (use "git add <file>..." to include in what will be committed)


README


再创建一个文件新README 文件而未经过git add

 git status

On branch master


No commits yet


Changes to be committed:

  (use "git rm --cached <file>..." to unstage)


new file:   1.py

new file:   1.txt


Untracked files:

  (use "git add <file>..." to include in what will be committed)


README


经过add的文件用git commit命令来提交本地库

之后会生成2个关于commit的object

➜  test git:(master) git cat-file -p 8d2a2200237c6a6480a053cd460546603303e68a 

100644 blob 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 1.py

100644 blob cdbb2ce4ae5b3765b0d33a1acbff426c258b4bcd 1.txt

100644 blob 8178c76d627cade75005b40711b92f4177bc6cfc README

➜  test git:(master) git cat-file -p 7ffec2a505a1f366504f9418c2d26f817c8dadbb 

tree 8d2a2200237c6a6480a053cd460546603303e68a

author hello <cqia2357@uni.sydeny.edu.au> 1521938061 +1100

committer hello <cqia2357@uni.sydeny.edu.au> 1521938061 +1100


First Commit




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值