Git status shows files as changed even though contents are the same

Problem Statement : “Git status” – shows a number of unwanted modified files 

After cloning the git repository if you fire git status and discovers that there are lot of modified files which you have not even touched/modified then the issue is definitely of Git Munging EOL (LF to CR/LF)

Step by Step solution –

1. Discard your local changes :
If you have any modification, take their back in some notepad file other then git repository, because in the process of solving this issues you might loose your commits, also this solution will not work if you have some modified changes in you repository.

2. Run below commands :

git rm --cached -r .
# Remove everything from the index. git reset –hard
# Write both the index and working directory from git's database.

3. Continue your work after pull
Now you can do a git pull and start adding code. Now with Git status you will not face the same problem again

Note : It may occur when you switch branches in git. So you might need to apply this solution every time you switch branch.

If you’ve ever developed on Linux, and then switched to Windows, you’ll notice that as soon as you checkout your repository all of your files are marked as changed. This is due to Git munging your EOL (line endings) – changing them from LF to CRLF.

Ref: Incorrect handling of Windows/Unix CR/LF

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.