I want git diff
to output normal, plain old diff output (not unified diff, and not context diff).
I want this:
$ diff file1 file2
2c2
< b
---
> B
4d3
< d
5a5
> f
I do NOT want unified output:
$ 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
I do NOT want context output:
$ 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
I tried the various git difftool --tool=
args with no luck, and I didn't find anything relevant in git diff --help
Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
When viewing a combined diff, if the two files you're comparing have a line that's different from what they were merged into, you will see the ++ to represent: one line that was added does not appear in either file1 or file2.
You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.
There is no output to git diff because Git doesn't see any changes inside your repository, only files outside the repository, which it considers 'untracked' and so ignores when generating a diff.
git difftool --extcmd=diff
or, without prompting:
git difftool --extcmd=diff --no-prompt
This is git difftool
rather than git diff
but it is doing what I want.
You can use same script (see man git(1) for details):
$ 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With