Git says “Binary files a… and b… differ” on for *.reg files

后端 未结 4 1605
刺人心
刺人心 2021-02-19 14:47

Is there a way to force Git in to treating .reg files as text? I am using Git to track my windows registry tweaks and Windows uses .reg for these files

4条回答
  •  清酒与你
    2021-02-19 15:08

    Git is treating your registry export files as binary files because they have NULs. There is no good way to diff or merge general binary files. A change of one byte can change the interpretation of the rest of the file.

    There are two general approaches to handling binary files:

    1. Accept that they're binary. Diffs aren't going to be meaningful, so don't ask for them. Don't ever merge them, which means only allowing changes on one branch. In this case, this can be made easier by putting each tweak (or set of related tweaks in a separate file, so there's fewer possible ways differences will happen in one file.

    2. Store the changes as text, and convert/deconvert to these binary forms.

    Even though these "text" files, the UTF-16 encoding contains NULs. There appear to be no non-ASCII bits however. Can you convert them to ASCII (or UTF-8, which will be ASCII if there are no extended characters)?

提交回复
热议问题