一、 初始化
E:\>mkdir git
E:\>cd git
E:\git>git init
Initialized empty Git repository in E:/git/.git/
E:\git>git add ./readme.txt
E:\git>git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: readme.txt
E:\git>git commit -m "add a readme"
[master (root-commit) b797535] add a readme
1 file changed, 1 insertion(+)
create mode 100644 readme.txt
E:\git>git commit -m "change readme"
[master 36d730c] change readme
1 file changed, 2 insertions(+), 1 deletion(-)
E:\git>git reset --hard HEAD~2
HEAD is now at b797535 add a readme
E:\git>git reflog
4f79e01 (HEAD -> master) HEAD@{0}: commit: change 2
2fd38c4 HEAD@{1}: commit: change 1
b797535 HEAD@{2}: reset: moving to HEAD~2
15cc4f8 HEAD@{3}: commit: change readme
36d730c HEAD@{4}: commit: change readme
b797535 HEAD@{5}: commit (initial): add a readme
E:\git>git reset --hard 15cc4f8
HEAD is now at 15cc4f8 change readme