Reputation: 16321
In the gitattributes you can specify that a specific file type should be treated as binary, e.g.
*.myExt binary
From:
http://git-scm.com/docs/gitattributes
This means that no line ending conversion will be applied or that textual diffs will be produced.
But what happens if I need to merge the content anyway? Will git try to merge it or simply skip all file types listed as binary
in the gitattributes file?
Its not clear from: http://git-scm.com/docs/gitattributes
if file types marked as binary will be merged (meaning that git will try to do a merge/report possible conflict or simply skip this type off file).
Upvotes: 2
Views: 4187
Reputation: 78743
If you mark a file as binary
, then it is not automergeable. If two branches both change the file then git will refuse to perform the merge and will simply mark the file as a conflict:
% cat .gitattributes
foo.txt binary
% git merge branch
warning: Cannot merge binary files: foo.txt (HEAD vs. branch)
Auto-merging foo.txt
CONFLICT (content): Merge conflict in foo.txt
Automatic merge failed; fix conflicts and then commit the result.
However, if you want to allow the files to be automergeable but still keep the other effects of the binary
attribute - namely, removing CR/LF conversion from the implied -text
attribute, and removing diff'ability from the implied -diff
attribute, then you can set the merge
attribute:
% echo 'foo.txt binary merge' > .gitattributes
% cat .gitattributes
foo.txt binary merge
% git merge branch
Auto-merging foo.txt
Merge made by the 'recursive' strategy.
foo.txt | Bin 112 -> 112 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
Upvotes: 5