我刚刚遇到了一个类似的问题(可能由于 git gui 的工作原理相同),这对任何拥有它的人都可能有用。
通过 修补我的 pom.xml 时git add -e pom.xml
,补丁如下。
diff --git a/pom.xml b/pom.xml
index 3dba69a..a9c8ebb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,26 +1,48 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>adowrath</groupId>
<artifactId>project-name</artifactId>
<version>0.0.1</version>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.7.9</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>report</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
@@ -32,9 +54,15 @@
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>2.5.5</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
我想删除最后一个具有 Mockito 依赖项的块。如果我只是删除这些行本身,它总是会给我一个错误报告到第 64 行:
fatal: corrupt patch at line 64
fatal: Could not apply '.git/ADD_EDIT.patch'
第 64 行是补丁文件的最后一行,所以 <project>
.
解决方案是简单地移除整个主干,因此从@@-line 向下的所有内容都可以立即工作。
我希望这有帮助。