0

I have started to use the Git staging in "Eclipse Jee Oxygen". Everytime I make a small change to a file(fix a bug), I have to commit and push. But in git, the entire file is shown to have changed. Why is this happening? This confuses other people working on the same repository.

How do I resolve this issue to commit and push only changes from Git staging view of Eclipse?

Any help is appreciated.

2
  • Do you mean git diff show all lines of file being removed and added, but not only modified lines? Could it be line ending issue? Nov 14, 2018 at 8:55
  • @PetSerAl No. In github, the changes made for a commit are shown. While I have changed only few lines, it shows the entire file to have changed after I have used the commit and push in the git stage view.
    – Eswar
    Nov 14, 2018 at 9:37

1 Answer 1

1

That's because there was a change in EOL format for the file.

There are different EOL (end of line) formats. UNIX uses LF as a line break, windows uses CRLF, Macs use a different thing. Decent text editors recognize the format of a file and keep that when saving the file (Windows notepad is not on the list of decent text editors. It has historically messed them up... why? Because who uses anything but Windows??? Anyway). Working on multi-OS environments, this can be a tricky subject.

Now, when you change the EOL format for a given file on a revision (willingly or unwillingly), for VCSs it's like the whole file changed, which is what you are seeing.

Git provides a few tricks to try to keep this from happening. There was an old implementation for this (using autocrlf, I think) that was pretty messy, though it's still available (and that's probably what's causing you trouble by changing the EOL format of files behind your back). Then there was another attempt which is much better that uses attributes. In general, the best thing you can do is tell git to let the files be as is and not mess up with the EOL format of files by adding this line to .git/info/attributes:

* -text

Hope that helps.

3
  • I appreciate your help but I didn't get what exactly do I do to solve the problem. Can you be more specific please.
    – Eswar
    Nov 15, 2018 at 4:49
  • the attributes folder isn't there in .git/info. Btw, I'm working on windows system. There's a exclude folder in the above location. Will the problem be solved if I tweak the .git/config file?
    – Eswar
    Nov 16, 2018 at 7:40
  • .git/info/excludes works as part of the .gitignore system.... so no, it's not what you need. If the file doesn't exist, feel free to create it.
    – eftshift0
    Nov 16, 2018 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.