Information Technology Reference
In-Depth Information
Finally, merge the fr branch into en with the $ git merge fr command. This
time you will get the message:
warning: Cannot merge binary files: numbers.txt (HEAD vs.
fr)
Auto-merging numbers.txt
CONFLICT (content): Merge conflict in numbers.txt
Automatic merge failed; fix conflicts and then commit the
result.
As you can see the numbers.txt files are treated as binary files. The command $
cat numbers.txt prints:
1
two
3
Thus the two versions of the files were not merged. The working directory contains
the version taken from the en branch (which is currently --ours ).
How It Works
How does git know which files are binary and which have textual contents? It checks
first 8,000 bytes of the file for the occurrence of a NULL byte. If the file contains the
byte with the code 0, it is assumed to be a binary file. Otherwise it is treated as text file.
To force a file to be treated as binary you can use the:
filename binary
rule in the .gitattributes file. Likewise, you can also force a binary file to be
treated as a text file with the following rule:
filename text
In both cases the filename can be replaced with a pattern. Here are two ex-
amples: the first forces all files under bindir/ to be treated as binary, the other forces
all the files with names ending with .xyz to be treated as text files:
Search WWH ::




Custom Search