gitgit-commitgit-pusheclipse-oxygengit-stage

Commit and Push in eclipse commits entire file as changed


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.


Solution

  • 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.