fst*_*tab 32 git diff git-diff
我想知道是否可以将一定量的未解析内容添加到作为注释被忽略的diff文件(统一)中.
一个很好的用途是使用git diffs扩充重要信息,例如从哪个分支到diff(特别是在使用--full-index选项时,它只显示blob引用).
Jak*_*tka 48
统一差异以两个行标题开头:
--- from-file from-file-modification-time
+++ to-file to-file-modification-time
Run Code Online (Sandbox Code Playgroud)
忽略此标头之前的任何内容,因此您可以在此处添加任何注释,例如:
This may be some useful description of this patch that
will be ignored by the diff/patch utility.
--- a/foo 2002-02-21 23:30:39.942229878 -0800
+++ b/foo 2002-02-21 23:30:50.442260588 -0800
@@ -1,7 +1,6 @@
-The Way that can be told of is not the eternal Way;
-The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
-The Named is the mother of all things.
+The named is the mother of all things.
+
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
Run Code Online (Sandbox Code Playgroud)
Git本身在标题之前使用此空间来存储某些元数据,例如:
diff --git a/foo b/foo
index 59a4d1f..e48dfe7 100644
--- a/foo
+++ b/foo
Run Code Online (Sandbox Code Playgroud)
xuh*_*dev 11
您可以在diff文件中使用#而不是-或+在diff文件中使用(可以通过GNU补丁识别),或者在@JakubJirutka提到的开头添加注释
This may be some useful description of this patch that
will be ignored by the diff/patch utility.
--- a/foo 2002-02-21 23:30:39.942229878 -0800
+++ b/foo 2002-02-21 23:30:50.442260588 -0800
@@ -1,7 +1,6 @@
# comments on the deletion of the two lines
-The Way that can be told of is not the eternal Way;
-The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
-The Named is the mother of all things.
+The named is the mother of all things.
+
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
Run Code Online (Sandbox Code Playgroud)
同一行@@ 之后的任何内容也将被忽略。
--- a/foo 2002-02-21 23:30:39.942229878 -0800
+++ b/foo 2002-02-21 23:30:50.442260588 -0800
@@ -1,7 +1,6 @@ THIS IS A COMMENT THAT WILL BE IGNORED
-The Way that can be told of is not the eternal Way;
-The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
-The Named is the mother of all things.
+The named is the mother of all things.
+
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
Run Code Online (Sandbox Code Playgroud)