简体   繁体   English

防止 GIT 自动更改字符编码

[英]Prevent GIT from changing automatically character encoding

I face a problem as below.我面临如下问题。 Please give me a solution.请给我一个解决方案。 Thanks in advance!提前致谢!

I use Linux OS (ubuntu)我使用 Linux 操作系统 (ubuntu)

Initially, I checkout new branch with the file test.properties file encoding:最初,我使用文件test.properties文件编码签出新分支:

test.properties: text/plain; charset=unknown-8bit

Intellij Seting file encoding: Intellij 设置文件编码: 在此处输入图片说明

on Browser, the text show like:在浏览器上,文本显示如下:

# 基本情報

I only add '#' character for one line, then I commit file, push my_branch to my repository I run git diff command:我只为一行添加“#”字符,然后我提交文件,将 my_branch 推送到我的存储库我运行git diff命令:

git diff
    -# <8A><EE><96>{<8F><EE><95><F1>
    +## \u57FA\u672C\u60C5\u5831

.... other lines are also changed into UTF-8 encoding. ....其他行也改成UTF-8编码。

How can I prevent the problem?我怎样才能防止这个问题? Simply, It just marks as below: My expectation looks like this:简单地说,它只是标记如下:我的期望是这样的:

-# <8A><EE><96>{<8F><EE><95><F1>
+## <8A><EE><96>{<8F><EE><95><F1>

I've found out the cause.我已经找出原因了。 It comes from changing setting from IDE.它来自从 IDE 更改设置。

I unchecked Transparent native-to-ascii conversion as below:我取消选中Transparent native-to-ascii 转换,如下所示: 在此处输入图片说明

Ok, now the merge request only showed what was changed.好的,现在合并请求只显示更改的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM