8

I have been working on a project and edited a bunch of files in a folder. This folder resides on my local and not watched by GIT. I usually copy the entire folder into another computer that is watched by GIT to be pushed to the repo. The problem now is that a bunch of files are being shown as changed due to line endings and spaces being shown up, as it's being copied from windows to a linux box.

I did the following command: git diff --stat to show all the files changed with the # of lines/characters changed.

enter image description here

As you can see many of these files have zero changes done to them. However, they still show up in my git status modified section.

How do I remove or revert these back to normal as I never changed anything with these files?

Patoshi パトシ
  • 21,707
  • 5
  • 29
  • 47

2 Answers2

5

Check your configuration on your destination Git repo in which you copy those files.

git config core.autocrlf

Make sure to set it to false: git config core.autocrlf false (see more here).

Then double-check the presence and content of .gitattributes files. They can influence eol as well with core.eol directives.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I think it is more likely that these files are showing up due to mode changes. Try running git diff on one of them. Do you see something like this?

$ git diff query.viewport.js
diff --git a/query.viewport.js b/query.viewport.js
old mode 100644
new mode 100755

If so, then you might be able to solve this with something like:

$ find modules/hotsite/ -type f -print0 | xargs -0 chmod -x
Chris
  • 451
  • 2
  • 5