Geraint
Geraint

Reputation: 41

Git commit show total file replacement instead of line by line changes

Each time a colleague sends me a pull request and I view it at GitHub some of the files in the commit show up like completely new content e.g. 1200 line deletions and 1220 line additions where he as actually only added 20 new lines.

The files have not been reformatted and to the eye look barely changed and yet Git shows 100% pink followed by 100% green.

Any ideas what could be causing this would be very gratefully received.

Upvotes: 3

Views: 201

Answers (1)

AD7six
AD7six

Reputation: 66208

A real example would help but, most likely...

New lines

The line endings are different. Github has a helpful page explaining how to configure git so that it will transparently handle these differences:

git config --global core.autocrlf input
# Set this setting on OSX or Linux

git config --global core.autocrlf true
# Set this setting on Windows

You can also solve the problem by modifying editor settings.

See non-whitespace changes only

git diff can be used to see actual differences ignoring whitespace. It has various modes e.g.:

git diff --ignore-space-change someotherbranch

will output a diff ignoring differences that are indentation and line endings.

Upvotes: 5

Related Questions