You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode中未修改的gradlew.bat显示在变更列表且无法丢弃如何解决?

gradlew.bat无修改却显示Git变更的解决办法

问题现象

尝试丢弃gradlew.bat文件变更时出现异常:该文件未做任何修改,但在VSCode已变更文件区域仍然显示,且无法执行丢弃操作,手动对比文件也未发现内容差异。

报错信息

  • 执行git status返回结果:modified: android/gradlew.bat
  • 执行git diff返回内容如下:
diff --git a/android/gradlew.bat b/android/gradlew.bat
index ac1b06f9..107acd32 100644
--- a/android/gradlew.bat
+++ b/android/gradlew.bat
@@ -1,89 +1,89 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem      https://www.apache.org/licenses/LICENSE-2.0
-@rem
:

问题原因

该问题通常由Git换行符自动转换配置core.autocrlf触发:文件实际内容无变化,只是本地存储的换行符格式和仓库中存储的换行符格式不一致,才会出现无内容差异的修改提示,且常规的丢弃变更操作无法生效。

解决步骤

按顺序执行以下两个命令即可修复:

  1. git rm --cached -r .
  2. git reset --hard

内容的提问来源于stack exchange,提问作者Lovepreet Gill

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 17:06:01