c# - Git cant diff or merge .cs file in utf-16 encoding -


a friend , working on same .cs file @ same time , when there's merge conflict git points out there's conflict file isnt loaded usual "head" ">>>" stuff because .cs files binary files. added numerous things (*.cs text , on)- our .gitattributes file make git treat text file didnt work.

thats when realized git diff other .cs files , not one. reason because in unicode encoding contains chinese characters.

so how make git diff or merge files in utf-16 or utf-8 format?

the furstrating thing if push, gitlab shows whats different. dont how git can diff on server not bash.

i had similar problem *.rc files c++ project , found best way solve use git's smudge , clean filters store in repository utf-8, , convert utf-16 when writing working directory.

this way git such diffs, merges or whatever work on utf8 text without issue, working copy have utf16, keep visual studio happy.

to configure this, make sure you're using version of git has iconv available (the recent versions of msysgit do) , add following ~/.gitconfig file:

[filter "utf16"]     clean = iconv -f utf-16le -t utf-8     smudge = iconv -f utf-8 -t utf-16le     required 

then in .gitattributes file add:

*.rc filter=utf16 resource.h filter=utf16 

if have existing files in utf16 stored binary, need remove them repository , re-add them.

git rm --cached <names-of-utf16-files> git commit -am "removed utf16 files" git add <names-of-utf16-files> git commit -am "added utf16 files utf8" 

and should work.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -