|
[root@jroa git]# ll
total 4
-rw-r--r-- 1 root root 23 Oct 6 00:17 code.py
[root@jroa git]# git log --oneline #查看历史commit版本hash值82ec99e
82ec99e Delete file code.txt
924041d Modify file name code1.py-->code.txt
865c84e New add rom 'Sunshine Good~'
bf266f5 code1.py New add row Sunshine Good
7894d32 New add code1.py
b421347 New add code.py
[root@jroa git]# ll
total 4
-rw-r--r-- 1 root root 23 Oct 6 00:17 code.py
[root@jroa git]# git rm code.py #删除文件code.py
rm 'code.py'
[root@jroa git]# git commit -am "Delete file code.py" #commit -am等价于执行 #git add filename # git commit -m "Delete fie code.py",提示删除成功
[master 3271a1d] Delete file code.py
1 files changed, 0 insertions(+), 1 deletions(-)
delete mode 100644 code.py
[root@jroa git]# ll #查看不存在
total 0
[root@jroa git]# git status #也没报错
# On branch master
nothing to commit (working directory clean)
[root@jroa git]# git log --oneline #查看commit版本hash值
3271a1d Delete file code.py
82ec99e Delete file code.txt
924041d Modify file name code1.py-->code.txt
865c84e New add rom 'Sunshine Good~'
bf266f5 code1.py New add row Sunshine Good
7894d32 New add code1.py
b421347 New add code.py
[root@jroa git]# git reset --hard 82ec99e #回滚到上个版本
HEAD is now at 82ec99e Delete file code.txt
[root@jroa git]# ll #OK文件回来了
total 4
-rw-r--r-- 1 root root 23 Oct 6 00:18 code.py
[root@jroa git]# git log --oneline #回滚成功
82ec99e Delete file code.txt
924041d Modify file name code1.py-->code.txt
865c84e New add rom 'Sunshine Good~'
bf266f5 code1.py New add row Sunshine Good
7894d32 New add code1.py
b421347 New add code.py
|
|
|
|
|
|
|