Information Technology Reference
In-Depth Information
• What can happen when two people modify exactly the same line of a text
file?
• Whatcanhappenwhentwodeveloperschangethesamebinaryfilestoring
different contents in them?
• How does git decide which files are binary and which are not?
The first problem, the overlapping changes in a text file, will result in a textual con-
flict during merge or rebase operations. In both cases, the operation is paused, and you
have to resolve all conflicts. When conflicts are resolved you can finish merging using
the $ git commit command. To resume paused rebase use the $ git rebase -
-continue command.
Conflicted text files are denoted as UU by the $ git status -s command. The
overlapping parts are marked with <<<<<<<, =======, >>>>>>> . The length of
these markers can be adjusted with the conflict-marker-size attribute presen-
ted in Table 9-2 . You have to manually edit the file and decide what you consider ap-
propriate contents for every conflict. Remember that you do not resolve the conflict by
removing the markers <<<<<<< , ======= , >>>>>>> . Even if you remove all mark-
ers and save the file it is still in an UU state. To change the state of the file from UU to
M_ you have to stage the file. This can be done with the $ git add [filename]
command.
Binary files also can cause a conflict, but in that case git cannot merge two different
binary files into one file. You will be left with the first or second version of a file, de-
pending on whether you used merge or rebase. Conflicted binary files are denoted as
AA . The conflict is resolved exactly as in textual case by staging the file with the $
git add [filename] command.
In case of textual conflict the following four commands can be used to generate four
versions of conflicted files:
$ git checkout --ours [filename]
$ git checkout --theirs [filename]
$ git checkout --merge [filename]
$ git checkout --conflict=diff3 [filename]
For binary conflicts only the first two commands can be used.
How does git decide which files are binary and which are text? It browses the first
8,000 bytes of each file. If it finds a NULL byte the file is considered to be binary.
Otherwise the file is considered textual. You can also verbosely specify the type for
Search WWH ::




Custom Search