如何在1次提交中删除1个文件中的更改 [英] How can I remove a change in 1 file in 1 commit
本文介绍了如何在1次提交中删除1个文件中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在git commit中更改了3个文件。我不明白:
-
为什么git认为我在下面的文件中改变了?差异显示没有差异。
-
如何在git commit中删除此文件更改?
diff --git a / src / StateListener.java b / src / StateListener.java
index 0125c44 .. 6ba0874 100644
--- a / src / StateListener.java
+++ b / src / StateListener.java
@@ -7,8 +7,8 @@ import android.telephony .PhoneStateListener;
导入android.telephony.TelephonyManager;
导入android.util.Log;
-public class StateListener扩展PhoneStateListener {
+ public class StateListener扩展PhoneStateListener {
private Context mContext;
解决方案
这可能是一个空白的变化,撤消变化和 git commit --amend
它。
或者,以下内容:
$ git reset --soft HEAD ^
$ git checkout -f src / StateListener.java
$ git commit -c ORIG_HEAD
I change 3 files in my git commit. I don't understand:
why git thinks I change in the following file? The diff shows no difference.
how can i remove this file change in my git commit?
diff --git a/src/StateListener.java b/src/StateListener.java index 0125c44..6ba0874 100644 --- a/src/StateListener.java +++ b/src/StateListener.java @@ -7,8 +7,8 @@ import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log; -public class StateListener extends PhoneStateListener { +public class StateListener extends PhoneStateListener { private Context mContext;
解决方案
It is probably a whitespace change, undo the change and git commit --amend
it.
Alternatively do the following:
$ git reset --soft HEAD^
$ git checkout -f src/StateListener.java
$ git commit -c ORIG_HEAD
这篇关于如何在1次提交中删除1个文件中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文