Diff笔记

Posted by wsxq2 on 2018-04-07
TAGS:  diff

版权相关: 本文截取自读懂diff-阮一峰的网络日志

Unix diff

  1. normal

    $ diff f1 f2
       
    4c4
    < a
    ---
    > b
    
  2. context
    $ diff -c f1 f2
       
    *** f1 2012-08-29 16:45:41.000000000 +0800
    --- f2 2012-08-29 16:45:51.000000000 +0800
    ***************
    *** 1,7 ****
     a
     a
     a
    !a
     a
     a
     a
    --- 1,7 ----
     a
     a
     a
    !b
     a
     a
     a
    
  3. unified
    $ diff -u f1 f2
       
    --- f1 2012-08-29 16:45:41.000000000 +0800
    +++ f2 2012-08-29 16:45:51.000000000 +0800
    @@ -1,7 +1,7 @@
     a
     a
     a
    -a
    +b
     a
     a
     a
    

Git diff

$ git diff

diff --git a/f1 b/f1
index 6f8a38c..449b072 100644
--- a/f1
+++ b/f1
@@ -1,7 +1,7 @@
 a
 a
 a
-a
+b
 a
 a
 a