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

后端 未结 4 1594
刺人心
刺人心 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:02

    Create one utf16toascii.py:

    #!/usr/bin/env python3
    import sys
    data = open(sys.argv[-1]).read()
    ascii = data.decode('utf-16').encode('ascii', 'replace')
    sys.stdout.write(ascii)
    

    Then in bash do:

    $ echo "*.reg diff=utf16strings" >> .gitattributes
    $ git config --global diff.utf16strings.textconv /path/to/utf16toascii.py
    

    And you're good to diff registry files, as well as Xcode .strings files, or any other utf-16 file.

提交回复
热议问题