Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Git merge zip-archives, MS Office documents, etc?

Tags:

git

git-merge

Git for Windows.

I am learning Git. My project has some projectname.hmxz file instead of the simple text files. This file is a zip-archive (with the changed extension). It is a special file of project used by Help&Manual program. Can I use Git for such projects? It disturbs me, because each branch will have modified version of the projectname.hmxz file, which is not a usual text file. How Git will merge such branches with a single projectname.hmxz file? I think the same problem will be with MS Office documents: xls, doc, etc (because it is not a plain text also).

I haven't problems with usual text files, but what about such cases?

like image 408
Andrey Bushman Avatar asked Jul 17 '15 13:07

Andrey Bushman


2 Answers

Zip files:

No, they're binary. For binary files merge conflicts are resolved only as " use version A" or" use version B".

But if you build them from some source, maybe you can version-control that source.

MS Office files:

No, not possible. But they're often treated as text files, so at the first merge git will corrupt them. You should manually configure git to treat them as binary. Follow this instruction: https://stackoverflow.com/a/30731818/2790048

like image 156
Nick Volynkin Avatar answered Sep 28 '22 15:09

Nick Volynkin


You can't do much besides choosing one version over the other.

Say you're on the branch here and want to merge it with branch there. In order to do that, you'd have to use the ours option of the recursive strategy (by the way, note that recursive is the default merge strategy):

git merge --strategy=recursive -Xours there

To do the opposite thing (favor the files from there), run:

git merge --strategy=recursive -Xtheirs there

Be wary that it affects conflicts for all files, not just binary files!

For more information see git-merge(1) manpage. I don't know the Windows equivalent, but you can also find it at the following link: https://git-scm.com/docs/git-merge

like image 31
werkritter Avatar answered Sep 28 '22 15:09

werkritter