I have tried all the methods in it and searched through Baidu and Google. https://my.oschina.net/lujian...
走同樣的路,發(fā)現(xiàn)不同的人生
I don’t know the specific reason, but I have encountered similar situations before. I may have some experiences that you can refer to:
Don’t use git on msys or cygwin, use the official git one. Because the git on cygwin thinks it is a Linux environment, the default encoding is UTF, and Windows does not use UTF, so when adding, it will not be recognized as Windows and will not be transcoded for you, resulting in garbled code.
If there is an encoding problem, do not try to modify the default configuration first, but refer to 1
Do not copy git repositories of different platforms directly. Git itself has done a lot of compatibility work, such as line endings. If you copy it directly, git will not be able to modify the line endings, and then when you git status, you will find that all files have changed.
Well, if you use the official git again and the default encoding configuration, there will probably be no problems.
Show you what I used git bash
的配置吧,不知道哪一句的作用commitencoding
提交和保存在版本庫里 log 的編碼,如果你不知道保存在庫實(shí)際的編碼那就沒辦法了。logoutputencoding
應(yīng)該是交給shell
時(shí)候使用的編碼,如果不相同應(yīng)該會(huì)進(jìn)行轉(zhuǎn)換。gui.encoding
似乎是設(shè)置git bash
使用的編碼,這個(gè)要和logoutputencoding
,我都設(shè)置成utf-8
.
[i18n]
commitencoding = utf-8
logoutputencoding = utf-8
[gui]
encoding = utf-8
[core]
quotepath = false
[i18n "commit"]
encoding = utf-8