BenMills
BenMills

Reputation: 1095

Entire file conflicting in git after first two lines

Between myself and another programmer who are working on the same project we consistently have a problem with git where we will commit a few changes to a specific file, push the changes up, and when the other pulls down the entire file is conflicted. It only happens with one file in our repository.

Also we noticed in github when you view that file it only shows the first two lines. However when you view it as raw it contains the entire file.

Upvotes: 2

Views: 375

Answers (2)

mmmmmm
mmmmmm

Reputation: 32720

Are you on Windows if so perhaps the file has Unix end of line markers which things like notepad see as one line. So you probably do see the whole file but you need to scroll to the right to see the other lines.

You can set git to convert line endings. From github Dealing with line endings

The git config core.autocrlf command is used to change how Git handles line endings. It takes a single argument.

On OS X, you simply pass input to the configuration. For example:

git config --global core.autocrlf input
# Configure Git on OS X to properly handle line endings

On article is from Coding Horror

Upvotes: 2

Greg Hewgill
Greg Hewgill

Reputation: 994767

Is it possible that file somehow has an embedded NUL character? By your description of the formatted file view on Github being truncated, it sounds like that might be possible. I'm not sure what the internal merge in Git does when it encounters a NUL character.

If you have hexdump on OS X that will help, otherwise try od with a suitable set of options.

Upvotes: 0

Related Questions