Adam
Adam

Reputation: 2031

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.

Upvotes: 3

Views: 1222

Answers (2)

Ashutosh Jindal
Ashutosh Jindal

Reputation: 18869

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?

Upvotes: 3

Roland Smith
Roland Smith

Reputation: 43495

Creating a global gitattributes and gitconfig is probably the best way to go.

Git for windows 2 is based on MSYS2. This has an \etc directory somewhere. The best way to access it is probably to open an MSYS2 shell.

Upvotes: 0

Related Questions