0

git add . should be adding files which are new and modified. I did change only 2 files and when I run git status command it shows me that the whole project is modified. What can be the problem? Thank you

enter image description here

Nejweti
  • 113
  • 2
  • 11
  • you can check that by doing a `git diff` – zeekhuge Aug 30 '17 at 10:35
  • 4
    I'd guess that it's a line-ending difference. – Oliver Charlesworth Aug 30 '17 at 10:35
  • `git diff` shows me the specific changes made but still when I run `git add .` and `git status` it shows me all the repo is modified and it is giving my partners a hard time finding where i made the changes – Nejweti Aug 30 '17 at 10:46
  • Possible duplicate of [Git status shows files as changed even though contents are the same](https://stackoverflow.com/questions/5787937/git-status-shows-files-as-changed-even-though-contents-are-the-same) – phd Aug 30 '17 at 12:58

2 Answers2

0

Did you try with git diff to see what modification has been done, it can sometimes be ide which your using which may have caused some formatting in your files.

VIJ
  • 1,516
  • 1
  • 18
  • 34
0

As @Oliver mentioned in comments, it looks like its the line-ending difference.

To help you with that, I would quote two answeres :

First from here on how to show line ending differences in git diff :

First, make sure you're using the coloured output (e.g. with git diff --color) and that you've enabled whitespace highlighting with (e.g.)

git config color.diff.whitespace "red reverse"

This might not work in all cases, however, as git doesn't appear to highlight trailing whitespace for removed lines. To see whitespace that you've deleted, simply use

git diff -R

to put the whitespace on the 'added' side of the comparison, where it does get highlighted.

For more detail, see the answers at this SO question.

And second from here on how to fix the line-ending problem

GitHub suggests that you should make sure to only use \n as a newline character in git-handled repos. There's an option to auto-convert:

$ git config --global core.autocrlf true

Of course, this is said to convert crlf to lf, while you want to convert cr to lf. I hope this still works …

NOTE : Please refer to the original question/answers to make sure they fit in with what you need, as git repos usually contain priceless data and messing with them is not a good idea unless you know what you are doing.

zeekhuge
  • 1,594
  • 1
  • 13
  • 23