了解Git object,如blob、tree、commit等?
知道git reset --soft、git reset、git reset --hard的区别
听说过git reflog?
PPT or DEMO?
$ git init
$ echo '111' > a.txt
$ echo '222' > b.txt
$ git add *.txt
$ tree .git/objects
.git/objects
├── 58
│ └── c9bdf9d017fcd178dc8c073cbfcbb7ff240d6c
├── c2
│ └── 00906efd24ec5e783bee7f23b5d7c941b0c12c
├── info
└── pack
$ cat .git/objects/58/c9bdf9d017fcd178dc8c073cbfcbb7ff240d6c
xKOR0a044K%
$ git cat-file -t 58c9
blob
$ git cat-file -p 58c9
111
$ git commit -m '[+] init'
$ tree .git/objects
.git/objects
├── 0c
│ └── 96bfc59d0f02317d002ebbf8318f46c7e47ab2
├── 4c
│ └── aaa1a9ae0b274fba9e3675f9ef071616e5b209
...
$ git cat-file -t 4caaa1
tree
$ git cat-file -p 4caaa1
100644 blob 58c9bdf9d017fcd178dc8c0... a.txt
100644 blob c200906efd24ec5e783bee7... b.txt
$ git cat-file -t 0c96bf
commit
$ git cat-file -p 0c96bf
tree 4caaa1a9ae0b274fba9e3675f9ef071616e5b209
author lzane 李泽帆 1573302343 +0800
committer lzane 李泽帆 1573302343 +0800
[+] init
$ cat .git/HEAD
ref: refs/heads/master
$ cat .git/refs/heads/master
0c96bfc59d0f02317d002ebbf8318f46c7e47ab2
$ git reflog
e171c5f (HEAD -> article/git, origin/article/git) HEAD@{0}: commit: [+] writing
7788bcd HEAD@{1}: commit: [+] writing
adbb712 HEAD@{2}: commit: [*] 修改构建脚本
7341618 HEAD@{3}: commit: [+] writing
925c148 HEAD@{4}: pull: Fast-forward
6952e07 HEAD@{5}: commit: [+] writing
c92a024 HEAD@{6}: commit: [+] 添加文章内容
cfb234e (origin/master, origin/HEAD, master) HEAD@{7}: reset: moving to HEAD~2