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