Git Diff 格式
时间: 2023-07-06 18:31:11 浏览: 217
Git Diff 格式是 Git 版本控制系统使用的一种 Diff 格式,它可以显示修改的文件名、文件模式、文件内容等详细信息,支持多种输出格式。下面是 Git Diff 格式的一些常用选项和输出示例:
1. 显示修改的文件名和修改的行数:
```
git diff --stat
```
输出示例:
```
file1.txt | 10 +++++++++-
file2.txt | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
```
2. 显示修改的文件名和修改的内容:
```
git diff
```
输出示例:
```
diff --git a/file1.txt b/file1.txt
index 23f1a3b..a0c8f82 100644
--- a/file1.txt
+++ b/file1.txt
@@ -1,4 +1,4 @@
-This is the original content.
+This is the modified content.
And here is some more content.
-And some more.
+And even more.
```
3. 显示修改的文件名和上下文:
```
git diff --unified
```
输出示例:
```
diff --git a/file1.txt b/file1.txt
index 23f1a3b..a0c8f82 100644
--- a/file1.txt
+++ b/file1.txt
@@ -1,4 +1,4 @@
-This is the original content.
+This is the modified content.
And here is some more content.
-And some more.
+And even more.
```
4. 显示修改的文件名和某个文件的所有修改:
```
git diff <commit> <filename>
```
输出示例:
```
diff --git a/file1.txt b/file1.txt
index 23f1a3b..a0c8f82 100644
--- a/file1.txt
+++ b/file1.txt
@@ -1,4 +1,4 @@
-This is the original content.
+This is the modified content.
And here is some more content.
-And some more.
+And even more.
```
希望这些信息对您有帮助。
阅读全文