条件:
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ vim demo.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ ll
total 2
-rw-r--r-- 1 Administrator 197121 24 1月 5 02:12 demo.txt
-rw-r--r-- 1 Administrator 197121 122 1月 5 00:55 good.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
demo.txt
nothing added to commit but untracked files present (use "git add" to track)
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ git add demo.txt
warning: LF will be replaced by CRLF in demo.txt.
The file will have its original line endings in your working directory
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ git commit -m "创建demo.txt文件" demo.txt
warning: LF will be replaced by CRLF in demo.txt.
The file will have its original line endings in your working directory
[master 932c463] 创建demo.txt文件
1 file changed, 4 insertions(+)
create mode 100644 demo.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ git reflog
932c463 (HEAD -> master) HEAD@{0}: commit: 创建demo.txt文件
93d703a HEAD@{1}: commit: 删除apple.txt文件
d155333 HEAD@{2}: reset: moving to HEAD
d155333 HEAD@{3}: commit: 创建apple.txt文件
0cfd319 HEAD@{4}: reset: moving to 0cfd319
cc0df73 HEAD@{5}: reset: moving to cc0df73
0cfd319 HEAD@{6}: commit: 删除aaa.txt
cc0df73 HEAD@{7}: commit: 提交aaa.txt
3ada44f HEAD@{8}: reset: moving to 3ada44f
458cdc7 HEAD@{9}: reset: moving to 458cdc7
458cdc7 HEAD@{10}: reset: moving to 458cdc7
3ada44f HEAD@{11}: commit: 提交ffff
21b9c6b HEAD@{12}: commit: 提交eeeee
458cdc7 HEAD@{13}: commit: 提交dddd
0240249 HEAD@{14}: commit: 提交ccc
141db34 HEAD@{15}: commit: 版本提交
b3d2bc3 HEAD@{16}: commit (initial): My first commit.new file goo.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ rm demo.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: demo.txt
no changes added to commit (use "git add" and/or "git commit -a")
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ git add demo.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: demo.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ ll
total 1
-rw-r--r-- 1 Administrator 197121 122 1月 5 00:55 good.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ git reset --hard HEAD
HEAD is now at 932c463 创建demo.txt文件
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$ ll
total 2
-rw-r--r-- 1 Administrator 197121 28 1月 5 02:14 demo.txt
-rw-r--r-- 1 Administrator 197121 122 1月 5 00:55 good.txt
Administrator@DESKTOP-E9K0JSK MINGW64 /f/workspaces/git/weChat (master)
$