micromax 发表于 2018-9-17 10:01:04

Git 一些简单命令

# ll  
total 4
  
-rw-r--r-- 1 root root 23 Oct6 00:17 code.py
  
# git log --oneline                  #查看历史commit版本hash值82ec99e
  
82ec99eDelete file code.txt
  
924041dModify 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
  
# ll
  
total 4
  
-rw-r--r-- 1 root root 23 Oct6 00:17 code.py
  
# git rm code.py                         #删除文件code.py
  
rm 'code.py'
  
# git commit -am "Delete file code.py"   #commit -am等价于执行 #git add filename # git commit -m "Delete fie code.py",提示删除成功
  
Delete file code.py
  
1 files changed, 0 insertions(+), 1 deletions(-)
  
delete mode 100644 code.py
  
# ll                                    #查看不存在
  
total 0
  
# git status                            #也没报错
  
# On branch master
  
nothing to commit (working directory clean)
  
# git log --oneline                     #查看commit版本hash值
  
3271a1d Delete file code.py
  
82ec99eDelete file code.txt
  
924041dModify 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
  
# git reset --hard 82ec99e            #回滚到上个版本
  
HEAD is now at 82ec99eDelete file code.txt
  
# ll                                    #OK文件回来了
  
total 4
  
-rw-r--r-- 1 root root 23 Oct6 00:18 code.py
  
# git log --oneline                     #回滚成功
  
82ec99eDelete file code.txt
  
924041dModify 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


页: [1]
查看完整版本: Git 一些简单命令