我已经跑步:
\DateTime
然后我想通过键入git add -p
来分割我的帅哥:
s
我只想将 import org.hamcrest.CoreMatchers;
-import org.junit.Ignore;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? s
Sorry, cannot split this hunk
添加到提交中,而不要删除import org.junit.Before;
。我该怎么办?
答案 0 :(得分:2)
您可以通过键入e
来手动编辑该块,然后对其进行编辑,以使其仅包含所需的内容(请注意所有导入之前的空格,但要添加的除外):
# Manual hunk edit mode -- see bottom for a quick guide.
@@ -1,5 +1,5 @@
import org.hamcrest.CoreMatchers;
import org.junit.Ignore;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
这样您将获得:
+import org.junit.Before;
将位于登台区域,可以提交了(参见git diff --cached
)-import org.junit.Ignore;
将在工作目录中,可以随时添加到登台区域或进行更改(参见git diff
)提交后,您的HEAD
将显示(即git show HEAD
):
commit f2d890ec808c4ef35a4e77b7929bcfbc233101b4 (HEAD -> master)
Author: xxx
Date: Thu Jul 4 19:49:25 2019 +0100
Second
diff --git a/file.txt b/file.txt
index d1d0b87..462d075 100644
--- a/file.txt
+++ b/file.txt
@@ -1,5 +1,6 @@
import org.hamcrest.CoreMatchers;
import org.junit.Ignore;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;