LoginSignup
5

More than 5 years have passed since last update.

Git for Windowsのdiffの文字化けをどうにかする

Last updated at Posted at 2017-09-10

Git for Windowsで日本語が入ったファイルのdiffを取ると、UTF-8であろうとShift-JISであろうと文字化けすることがあります。

diff --git a/nihongo.txt b/nihongo.txt
index 0005c4e..5d6ea9c 100644
--- a/nihongo.txt
+++ b/nihongo.txt
@@ -1 +1 @@
-<E3><81><82><E3><81><84><E3><81><86><E3><81><88><E3><81><8A>
+<E3><81><8B><E3><81><8D><E3><81><8F><E3><81><91><E3><81><93>

LANG環境変数を正しく設定することで、この文字化けを回避することができます。

SETX LANG ja_JP.UTF-8

これで、うまく表示されるようになったはずです。

diff --git a/nihongo.txt b/nihongo.txt
index 0005c4e..5d6ea9c 100644
--- a/nihongo.txt
+++ b/nihongo.txt
@@ -1 +1 @@
-あいうえお
+かきくけこ

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5