Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF-16 support in Git for Windows 2.x

I work in a team on a development project that includes files created in SQL Server Management Studio (SSMS). The default file encoding for SSMS is: Codepage 1200 (Little-endian UTF-16).

Git for Windows recognises these files as binary. It is unable to show diff views of the files and it cannot merge files (remote merges overwrite the local version).

We are able to change the default encoding in SSMS easily. However, we prefer not to have risk of any UTF-16 files being committed - as they cause havoc in our source control and release mgmt processes.

This stack overflow post describes how to use Clean/Smudge filters to convert UTF-16 files to UTF-8 on the fly when committed, using two tools by GnuWin32: iconv, file.

This works well and we have been using it with msysgit 1.9.5 preview for a long time. However, this version is deprecated and the newer Git has more and more features that we require as a team. The problem is that this workaround relies on updating two files: Git\etc\gitattributes and Git\etc\gitconfig. These 2 files do not exist in Git for Windows 2.x

How can I add UTF-16 support to Git 2.x? Either by adapting the workaround for described for Git 1.x or by any other means.

like image 997
Adam Avatar asked Dec 22 '25 20:12

Adam


1 Answers

Configure the 2 files, system-wide (i.e. all users and all repos) as follows:

gitconfig

In your git for windows shell:

git config --system --edit

gitattributes

git config --system core.attributesfile <path>
and use whichever path you wish

Ofcourse, if you wish to reduce the scope to global (i.e. all repos for a specific user only) then, replace --system with --global.

Relevant questions:
Where should I place my global 'gitattributes' file?
Where do the settings in my Git configuration come from?
What is $(prefix) on $(prefix)/etc/gitconfig?

like image 67
Ashutosh Jindal Avatar answered Dec 24 '25 12:12

Ashutosh Jindal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!