How to fix: "git diff" does not show umlauts (or other non-ASCII characters) properly

Posted . Visible to the public.

When using git diff, you might encounter weird characters where umlauts (or any other UTF-8) characters should be. It looks like this:

R<C3><BC>ckg<C3><A4>ngig # should be "Rückgängig"

However, not Git is to blame but the less command Show archive.org snapshot that Git uses to page your diff output.

You need to tell less to use UTF-8 (otherwise it tries to convert multibyte chars like "ü" which is represented by 2 bytes C3 and BC).

$ LESSCHARSET=UTF-8 git diff

Doing it like above should fix it for that one command. If you want to persist that setting, say the following.

export LESSCHARSET=UTF-8

Put it into your ~/.bashrc and reopen all terminals (or source ~/.bashrc in open terminals).


Note that if you are having trouble with filenames, you should try changing git's core.precomposeunicode config setting.

Arne Hartherz
Last edit
Arne Hartherz
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2014-12-10 09:12)