我希望git diff
输出普通的普通旧差异输出(不统一差异,而不是上下文差异)。
我想要这个:
$ diff file1 file2
2c2
< b
---
> B
4d3
< d
5a5
> f
我不想要统一输出:
$ diff -u file1 file2
--- file1 2012-07-04 07:57:48.000000000 -0700
+++ file2 2012-07-04 07:58:00.000000000 -0700
@@ -1,5 +1,5 @@
a
-b
+B
c
-d
e
+f
我不想要上下文输出:
$ diff -c file1 file2
*** file1 2012-07-04 07:57:48.000000000 -0700
--- file2 2012-07-04 07:58:00.000000000 -0700
***************
*** 1,5 ****
a
! b
c
- d
e
--- 1,5 ----
a
! B
c
e
+ f
我尝试了各种git difftool --tool=
args而没有运气,我在git diff --help
答案 0 :(得分:14)
git difftool --extcmd=diff
或者,没有提示:
git difftool --extcmd=diff --no-prompt
这是git difftool
而不是git diff
,但它正在做我想要的。
答案 1 :(得分:2)
您可以使用相同的脚本(有关详细信息,请参阅man git(1)):
$ cat diff.sh
#!/bin/sh
# get args: path old-file old-hex old-mode new-file new-hex new-mode
diff "$2" "$5"
return=$?
if [ $return -le 1 ]; then
exit 0
else
exit $return
fi
$ GIT_EXTERNAL_DIFF=./diff.sh git diff HEAD^..HEAD