简体   繁体   中英

How to format the output of git diff

Is it possible to format the output of git diff so I'll get only the actual text difference?

for example, this is the default git diff output:

diff --git a/diff_test.txt b/diff_test.txt
index 6b0c6cf..b37e70a 100644
--- a/diff_test.txt
+++ b/diff_test.txt
@@ -1 +1 @@
-this is a git diff test example
+this is a diff example

Instead I want to get:

diff --git a/diff_test.txt b/diff_test.txt
-this is a git diff test example
+this is a diff example

is it possible with git diff or other git command without using other scripts like shell, python ,etc?

Excluding a diff patch header involves generally shell commands ( tail/sed )

You can only limit the context to only the modified line , but anything more, like hiding/remove the hunk headers, as in this answer , will involve some "non-git" command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM