43

I can't remember how I made Git GUI to display UTF-8 encoded differences correctly. Also I can't find the guide in search engines.

Now I need to do this at new workplace. Could you write down instructions?

OS: Windows 7

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
Paul
  • 25,812
  • 38
  • 124
  • 247
  • Please give more details about your setup - host OS type and version. If this is Linux or Mac, please show what `locale` says. – mvp Apr 18 '14 at 09:36

2 Answers2

84
# Global setting for all you repositories
> git config --global gui.encoding utf-8

# For one repository only
> git config gui.encoding utf-8

Or from the GUI window:

Edit -> Options... -> Default File Contents Encoding -> Change

and select "Unicode (UTF-8)"

In the Options, you'll see that there are two panel, the one on the right is for all repositories, the one on the left for the local repository.

Fabio Crisci
  • 1,125
  • 9
  • 16
  • Hm. This does not work for me... :( Are there more things that can be wrong, than this setting? – lindhe Nov 22 '19 at 17:09
  • @mikew Yes. This option specifies the default encoding of file contents for both git-gui and gitk. See [documentation](https://git-scm.com/docs/git-config#Documentation/git-config.txt-guiencoding) – brighteyed Mar 04 '20 at 10:02
  • 1
    in my case i have to restart gui to make the option effect. – Lei Yang Dec 02 '21 at 01:39
2

The file content encoding is clarified with Git 2.34 (Q4 2021):

See commit 1e93770, commit fd680bc (27 Aug 2021) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit bfe37f3, 10 Sep 2021)

docs: use "character encoding" to refer to commit-object encoding

Signed-off-by: Jeff King

The word "encoding" can mean a lot of things (e.g., base64 or quoted-printable encoding in emails, HTML entities, URL encoding, and so on).

The documentation for i18n.commitEncoding and i18n.logOutputEncoding uses the phrase "character encoding" to make this more clear.

Let's use that phrase in other places to make it clear what kind of encoding we are talking about.

This patch covers the gui.encoding option, as well as the --encoding option for git-log, etc (in this latter case, I word-smithed the sentence a little at the same time).
That, coupled with the mention of iconv in the --encoding description, should make this more clear.

git config now includes in its man page:

Specifies the default character encoding to use for displaying of

So git config gui.encoding utf-8 refers to character encoding, a mean to represent a repertoire of characters by some kind of encoding system that assigns a number to each character for digital representation.
(As opposed to a MIME Content-Transfer-Encoding like base64).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250