justHelloWorld
justHelloWorld

Reputation: 6842

gradlew.bat always changing after each commit in Android Studio

I've created my first Android Studio with Kotlin support, made a git project out of it, created a private github repository, added it to the remote in the project and did a first commit (not pushed yet).

However, as soon as I do a commit, there is always a new version of gradle.bat, which I shouldn't add to .gitignore.

Why, and how do I solve this?

Upvotes: 6

Views: 2415

Answers (2)

Francis Bacon
Francis Bacon

Reputation: 4785

Adding the following to .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

Reference: https://github.com/spring-projects/spring-security/issues/10039 https://github.com/spring-projects/spring-framework/blob/048954dc1db887ff31fbff76ad46e3d3b2f6040e/.gitattributes#L8 git apparently keeps saying that a file has been modified when it has not

Upvotes: 1

Khrystyna Skvarok
Khrystyna Skvarok

Reputation: 1198

For those who are having the same issue, it seems the timestamp of this file is changed by IDEs and that's why Git sees it as changed all the time. My solution was to add it to my global .gitignore file and run git update-index --assume-unchanged src/file/to/ignore command as this file is already marked in Git as changed.

Be aware, it's a local solution, this helps only for your local development.

Upvotes: 12

Related Questions