Search code examples
gitdiffgit-diff

Is there a way in GIT, to remove files changed from being committed if it has less than 2 characters changed?


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?


Solution

  • 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