玩龙天子 发表于 2018-9-17 09:34:33

Git reset 操作及介绍

# git log --oneline                     #查看log  
d322179 V0.0.2
  
a210ba7 V0.0.1
  
# ll                                    #查看工作区的文件
  
总用量 12
  
-rw-r--r-- 1 root root 22 10月 10 00:20 code1.py
  
-rw-r--r-- 1 root root 22 10月 10 00:20 code3.py
  
-rw-r--r-- 1 root root 22 10月 10 00:05 code.py
  
# git reset --hard HEAD^                #使用--hard回退
  
HEAD is now at a210ba7 V0.0.1
  
# ll                                    #查看文件,少了一个但是code3.py还在,是因为我们之前回退版本,该文件就没有被版本控制
  
总用量 8
  
-rw-r--r-- 1 root root 22 10月 10 00:20 code3.py
  
-rw-r--r-- 1 root root 22 10月 10 00:05 code.py
  
# git reset --hard b6d676f            #找打上面的v0.0.3,回退到该版本,发现一切都回来了
  
HEAD is now at b6d676f V0.0.3
  
# ll                                    #查看文件,完整
  
总用量 12
  
-rw-r--r-- 1 root root 22 10月 10 00:26 code1.py
  
-rw-r--r-- 1 root root 22 10月 10 00:26 code3.py
  
-rw-r--r-- 1 root root 22 10月 10 00:05 code.py
  
# git status                            #查看状态,一切都是干净的,说--hard影响index、HEAD、工作区也就是我们第二章图
  
# On branch master
  
nothing to commit (working directory clean)


页: [1]
查看完整版本: Git reset 操作及介绍