Prevent GIT from changing automatically character encoding

2k views Asked by At

I face a problem as below. Please give me a solution. Thanks in advance!

I use Linux OS (ubuntu)

Initially, I checkout new branch with the file test.properties file encoding:

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

Intellij Seting file encoding: enter image description here

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:

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

.... other lines are also changed into UTF-8 encoding.

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>
1

There are 1 answers

0
Mr Special On

I've found out the cause. It comes from changing setting from IDE.

I unchecked Transparent native-to-ascii conversion as below: enter image description here

Ok, now the merge request only showed what was changed.