blob: 7e36e5b55b1ab89ed67ca02f5327e928c853183d [file] [log] [blame]
Junio C Hamanod7ed4042015-08-03 19:43:001Git is to some extent character encoding agnostic.
Junio C Hamano775a0f42006-12-31 01:19:142
Junio C Hamano54bf1e22008-12-20 06:30:113 - The contents of the blob objects are uninterpreted sequences
Junio C Hamano775a0f42006-12-31 01:19:144 of bytes. There is no encoding translation at the core
5 level.
6
Junio C Hamanod7ed4042015-08-03 19:43:007 - Path names are encoded in UTF-8 normalization form C. This
8 applies to tree objects, the index file, ref names, as well as
9 path names in command line arguments, environment variables
10 and config files (`.git/config` (see linkgit:git-config[1]),
11 linkgit:gitignore[5], linkgit:gitattributes[5] and
12 linkgit:gitmodules[5]).
13+
14Note that Git at the core level treats path names simply as
15sequences of non-NUL bytes, there are no path name encoding
16conversions (except on Mac and Windows). Therefore, using
17non-ASCII path names will mostly work even on platforms and file
18systems that use legacy extended ASCII encodings. However,
19repositories created on such systems will not work properly on
20UTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa.
21Additionally, many Git-based tools simply assume path names to
22be UTF-8 and will fail to display other encodings correctly.
23
24 - Commit log messages are typically encoded in UTF-8, but other
25 extended ASCII encodings are also supported. This includes
26 ISO-8859-x, CP125x and many others, but _not_ UTF-16/32,
27 EBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5,
28 EUC-x, CP9xx etc.).
Junio C Hamano775a0f42006-12-31 01:19:1429
30Although we encourage that the commit log messages are encoded
Junio C Hamano076ffcc2013-02-06 05:13:2131in UTF-8, both the core and Git Porcelain are designed not to
Junio C Hamano775a0f42006-12-31 01:19:1432force UTF-8 on projects. If all participants of a particular
Junio C Hamano076ffcc2013-02-06 05:13:2133project find it more convenient to use legacy encodings, Git
Junio C Hamano775a0f42006-12-31 01:19:1434does not forbid it. However, there are a few things to keep in
35mind.
36
Junio C Hamano1aa40d22010-01-21 17:46:4337. 'git commit' and 'git commit-tree' issues
Junio C Hamano14b76482008-01-05 10:32:2638 a warning if the commit log message given to it does not look
Junio C Hamano775a0f42006-12-31 01:19:1439 like a valid UTF-8 string, unless you explicitly say your
40 project uses a legacy encoding. The way to say this is to
Junio C Hamano35bb3f62007-02-19 05:35:5341 have i18n.commitencoding in `.git/config` file, like this:
Junio C Hamano775a0f42006-12-31 01:19:1442+
43------------
Junio C Hamano35bb3f62007-02-19 05:35:5344[i18n]
Junio C Hamanobb34c102017-07-21 22:42:2845commitEncoding = ISO-8859-1
Junio C Hamano775a0f42006-12-31 01:19:1446------------
47+
48Commit objects created with the above setting record the value
Junio C Hamanobb34c102017-07-21 22:42:2849of `i18n.commitEncoding` in its `encoding` header. This is to
Junio C Hamano775a0f42006-12-31 01:19:1450help other people who look at them later. Lack of this header
51implies that the commit log message is encoded in UTF-8.
52
Junio C Hamano1aa40d22010-01-21 17:46:4353. 'git log', 'git show', 'git blame' and friends look at the
Junio C Hamanoaa17c7c2008-11-03 04:36:5854 `encoding` header of a commit object, and try to re-code the
55 log message into UTF-8 unless otherwise specified. You can
Junio C Hamano775a0f42006-12-31 01:19:1456 specify the desired output encoding with
Junio C Hamanobb34c102017-07-21 22:42:2857 `i18n.logOutputEncoding` in `.git/config` file, like this:
Junio C Hamano775a0f42006-12-31 01:19:1458+
59------------
Junio C Hamano35bb3f62007-02-19 05:35:5360[i18n]
Junio C Hamanobb34c102017-07-21 22:42:2861logOutputEncoding = ISO-8859-1
Junio C Hamano775a0f42006-12-31 01:19:1462------------
63+
64If you do not have this configuration variable, the value of
Junio C Hamanobb34c102017-07-21 22:42:2865`i18n.commitEncoding` is used instead.
Junio C Hamano775a0f42006-12-31 01:19:1466
67Note that we deliberately chose not to re-code the commit log
68message when a commit is made to force UTF-8 at the commit
69object level, because re-coding to UTF-8 is not necessarily a
70reversible operation.