如果没有删除任何行,git apply可以应用多次

时间:2018-07-30 15:42:23

标签: git patch git-apply

我有以下补丁

diff --git a/.htaccess b/.htaccess
index 4298b10..aa3d50d 100644
--- a/.htaccess
+++ b/.htaccess
@@ -364,6 +364,15 @@
             Require all denied
         </IfVersion>
     </Files>
+    <Files patches>
+        <IfVersion < 2.4>
+            order allow,deny
+            deny from all
+        </IfVersion>
+        <IfVersion >= 2.4>
+            Require all denied
+        </IfVersion>
+    </Files>

 # For 404s and 403s that aren't handled by the application, show plain 404 response
 ErrorDocument 404 /pub/errors/404.php

当我第二次使用git apply时,补丁不会失败,而是只是将其附加在同一行。有什么方法可以防止这种情况发生?

此外,当我使用git apply -R时,它将删除添加的实例之一。

1 个答案:

答案 0 :(得分:2)

简短的答案是否定的:git apply将传入的更改视为补丁,只需要找到正确的上下文即可。只要上下文继续匹配(在这种情况下也是如此),该修补程序就会继续适用。

这是避免使用补丁的原因之一,也许是主要原因。 git cherry-pick有更多可用信息,因此不会重新应用更改。