我创建了第一个支持 Kotlin 的 Android Studio,用它创建了一个 git 项目,创建了一个私有 github 存储库,将其添加到项目中的远程位置,并进行了第一次提交(尚未推送)。
但是,一旦我提交,总会有一个新版本的
gradle.bat
,我不应该将其添加到 .gitignore
。
为什么以及如何解决这个问题?
对于那些遇到同样问题的人来说,该文件的时间戳似乎已被 IDE 更改,这就是为什么 Git 始终将其视为已更改的原因。我的解决方案是将其添加到我的全局
.gitignore
文件中并运行 git update-index --assume-unchanged src/file/to/ignore
命令,因为该文件已在 Git 中标记为已更改。
请注意,这是一个本地解决方案,这只有助于您本地的发展。
将以下内容添加到 .gitattributes。
# Normalize line endings to LF.
* text eol=lf
# Ensure that line endings for multipart files in spring-web are not modified.
*.multipart -text
# Ensure that line endings for DOS batch files are not modified.
*.bat -text
# Ensure the following are treated as binary.
*.gif binary
*.jar binary
*.jpeg binary
*.jpg binary
*.png binary
*.vsd binary
参考: https://github.com/spring-projects/spring-security/issues/10039 https://github.com/spring-projects/spring-framework/blob/048954dc1db887ff31fbff76ad46e3d3b2f6040e/.gitattributes#L8 git 显然一直说文件已被修改,但实际上尚未修改