简体   繁体   English

如何在1次提交中删除1个文件中的更改

[英]How can I remove a change in 1 file in 1 commit

I change 3 files in my git commit. 我在git commit中更改了3个文件。 I don't understand: 我不明白:

  1. why git thinks I change in the following file? 为什么git认为我在以下文件中进行了更改? The diff shows no difference. 差异显示没有差异。

  2. how can i remove this file change in my git commit? 如何在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. 这可能是一个空白更改,请撤消更改并进行git commit --amend它。

Alternatively do the following: 或者,执行以下操作:

$ git reset --soft HEAD^
$ git checkout -f src/StateListener.java
$ git commit -c ORIG_HEAD

使用“ git checkout src / StateListener.java”放弃工作目录中的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM