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 againNote : It may occur when you switch branches in git. So you might need to apply this solution every time you switch branch.
Cause:
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.