git进阶 之 reflog

2020-06-03  本文已影响0人  诺之林

示例

mkdir git-demo && cd git-demo

git init
echo 0 > test

git add .

git commit -am "init 0" 

echo "1" >> test

git commit -am "add 1"

git checkout -b feature
git log --oneline
# cb41bee (HEAD -> master) add 1
# f9ca73f init 0

cat .git/refs/heads/master
# cb41beed05d68b8792d09b7125caad50acc95c7a

cat .git/HEAD
# ref: refs/heads/feature

提交

git进阶 之 object

Atlassian Refs and the Reflog

Git Documents git-log

引用

git进阶 之 reference

Atlassian Refs and the Reflog

Git Documents git-reflog

场景

git reset --hard HEAD^
# HEAD is now at f9ca73f init 0

git log --oneline
# f9ca73f (HEAD -> master) init 0

git reflog
# f9ca73f (HEAD -> master) HEAD@{0}: reset: moving to HEAD^
# cb41bee HEAD@{1}: commit: add 1
# f9ca73f (HEAD -> master) HEAD@{2}: commit (initial): init 0

git reset --hard HEAD@{1}
# HEAD is now at cb41bee add 1

git log --oneline
# cb41bee (HEAD -> master) add 1
# f9ca73f init 0

参考

上一篇下一篇

猜你喜欢

热点阅读