Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does git see whole files as changed when copying files overtop of other files?

Tags:

git

When I copy a file over top of another file in a git controlled directory... I'm seeing git think that the whole file has changed instead of one small hunk... why?

Here is an example of what I mean... http://github.com/cmodien/fileupdatetest/commit/90309ed099e257cd98218b4504cd2cd3a3a47a27

OK... I checked the line endings on the file... The original file has crlf line endings. The file that I pasted over the original has lf line endings. Which makes sense I guess... I got the original file from a windows user and I received the new file from a mac user.

How do I fix this?

like image 866
Clintm Avatar asked Jun 28 '10 22:06

Clintm


Video Answer


1 Answers

As mentioned on twitter, (@adymitruk) you have an issue with line endings. The AutoCRLF setting is probably not set to "false" as it should be - unless you are doing cross-platform development.

The solution is to set it to false, fix the line endings set the autocrlf to false then commit. When this is done, you will be able to copy those files and then only see the actual changes.

like image 141
Adam Dymitruk Avatar answered Sep 20 '22 00:09

Adam Dymitruk