2

I have a repository cloned from GitHub, and I made changes to file A, however Git is detecting changes to file B,C and D. All three files are detecting the changes as basically the entire contents of B,C,D. i.e. +all lines in B,C,D, -all lines in B,C,D.

I don't want to commit this as it makes for a dirty commit. Why is git detecting these changes and how to I get git to ignore these changes forever?

The project is in C#, I use the GitHub windows application and the IDE is VS Express 2012.

Edit: I realize the files have changed, but is there a way to a) find out what changed and b) tell git to ignore them and not pick them up again between commits. It seems my editor is modifying files B,C,D in some way after I first openened the cloned project.

Even after running a git reset --hard, git diff still reports the changes.

Kara
  • 6,115
  • 16
  • 50
  • 57
Vort3x
  • 1,778
  • 2
  • 20
  • 37
  • git will not do that. The files are probably being changed by an editor you use. If git says it has changed, be assure the file *has* changed. – Aras Nov 07 '12 at 05:47
  • @Aras I edited question, I know they have changed and realize Git is not making a mistake, but how do I get Git to ignore them. – Vort3x Nov 07 '12 at 05:59
  • Why not commit them then amend the commit later once something of value is actually going to be committed? What do you gain from not wanting to commit these files anyway? – Simon Whitehead Nov 07 '12 at 06:13
  • @SimonWhitehead I feel finding the root of the cause and solving that is better than just ignoring the problem :D – Vort3x Nov 07 '12 at 15:50

2 Answers2

2

You probably need to tell git about your line ending strategy.

See the following resources for more information on this subject

Note: Short time fix would require to tweak the core.autocrlf setting on your computer. The correct fix would be to create a .gitattributes files, commit it, and send a Pull Request to the upstream repository you've cloned. Indeed, it would not only fix your issue, but would also prevent new users from stumbling on the same problem later.

An example of a valid, C# project compatible, cross platform .gitattributes file can be found here. Feel free to get some inspiration from it ;-)

A very detailed blog post about line endings and Git inner workings is Mind the end of your line. It's very well worth the read.

nulltoken
  • 64,429
  • 20
  • 138
  • 130
1

This is probably related to the eol (end of line) style, as explained in Github page "Dealing with line endings".

I would recommend:

git config --global core.autocrlf false
git clone https://github.com/user/repo newrepo

And see if in that new repo the issue persists.

There are reason to have core.autocrlf activated, but it causes more problem than it solves.
You can manage the end of lines with other settings (see this question).

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