Git-删除文件后找回-比较文件差异

#前提:删除前,文件存在是的状态提交到了本地库
#操作: git reset --hard 指针位置
    删除操作已近提交到本地库:指针指向历史记录
    



linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work $ cd Test/ linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ vim aaa.txt linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ git add aaa.txt warning: LF will be replaced by CRLF in aaa.txt. The file will have its original line endings in your working directory linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ git commit -m "new txt" aaa.txt warning: LF will be replaced by CRLF in aaa.txt. The file will have its original line endings in your working directory [master 5723a86] new txt 1 file changed, 2 insertions(+) create mode 100644 aaa.txt linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ git status On branch master nothing to commit, working tree clean linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ rm aaa.txt linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ ll total 1 -rw-r--r-- 1 linxianli 1049089 125 四月 25 16:32 good.txt linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ git status On branch master Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) deleted: aaa.txt no changes added to commit (use "git add" and/or "git commit -a") linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ git refloog git: 'refloog' is not a git command. See 'git --help'. The most similar command is reflog linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ git reflog 5723a86 (HEAD -> master) HEAD@{0}: commit: new txt c37331e HEAD@{1}: reset: moving to HEAD c37331e HEAD@{2}: reset: moving to c37331e c37331e HEAD@{3}: reset: moving to c37331e dbc8b46 HEAD@{4}: reset: moving to HEAD^ c37331e HEAD@{5}: reset: moving to c37331e ea4d3ce HEAD@{6}: commit: 10 c37331e HEAD@{7}: commit: 9 dbc8b46 HEAD@{8}: commit: 8 719c75a HEAD@{9}: commit: 7 ca821b6 HEAD@{10}: commit: 6 060a421 HEAD@{11}: commit: 5 8d1f64d HEAD@{12}: commit: 4 de0c64e HEAD@{13}: commit: 3 9718c85 HEAD@{14}: commit: second commit,modify 14e7a11 HEAD@{15}: commit (initial): first commit linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ git reset --hard ^C linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ git reset --hard 5723a86 HEAD is now at 5723a86 new txt linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $ ll total 2 -rw-r--r-- 1 linxianli 1049089 12 四月 26 11:42 aaa.txt -rw-r--r-- 1 linxianli 1049089 125 四月 25 16:32 good.txt linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master) $

 

 

比较文件差异:

    git diff [文件名]

      将工作区的文件和暂存区的文件进行比较

      git diff [本地库中的历史版本] [文件名]

       将工作区中的文件和本地库的历史记录进行比较

     git diff

       不带文件名就是比较多个文件

 

linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master)
$ vim good.txt

linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master)
$ git diff
diff --git a/good.txt b/good.txt
index 5e87980..69eb60a 100644
--- a/good.txt
+++ b/good.txt
@@ -9,3 +9,4 @@ ijfksdahkfh
 kjlhkjhkjs
 dsaklfhkjla
 sdfsfsfsdfdsf
+ABC

linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master)
$ git diff HEAD
diff --git a/aaa.txt b/aaa.txt
index 051eb5a..f2be101 100644
--- a/aaa.txt
+++ b/aaa.txt
@@ -1,2 +1,3 @@
 aa a
 bbbb
+vvvvv
diff --git a/good.txt b/good.txt
index 5e87980..69eb60a 100644
--- a/good.txt
+++ b/good.txt
@@ -9,3 +9,4 @@ ijfksdahkfh
 kjlhkjhkjs
 dsaklfhkjla
 sdfsfsfsdfdsf
+ABC

linxianli@VM-QS-004 MINGW64 /c/LXL Working-Place/Git-Work/Test (master)
$

 

转载于:https://www.cnblogs.com/LXL616/p/10773436.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值