2015-07-01 19:10:47 +00:00
|
|
|
Git is to some extent character encoding agnostic.
|
2006-12-30 10:22:38 +00:00
|
|
|
|
2008-12-19 12:14:18 +00:00
|
|
|
- The contents of the blob objects are uninterpreted sequences
|
2006-12-30 10:22:38 +00:00
|
|
|
of bytes. There is no encoding translation at the core
|
|
|
|
level.
|
|
|
|
|
2015-07-01 19:10:47 +00:00
|
|
|
- Path names are encoded in UTF-8 normalization form C. This
|
|
|
|
applies to tree objects, the index file, ref names, as well as
|
|
|
|
path names in command line arguments, environment variables
|
|
|
|
and config files (`.git/config` (see linkgit:git-config[1]),
|
|
|
|
linkgit:gitignore[5], linkgit:gitattributes[5] and
|
|
|
|
linkgit:gitmodules[5]).
|
|
|
|
+
|
|
|
|
Note that Git at the core level treats path names simply as
|
|
|
|
sequences of non-NUL bytes, there are no path name encoding
|
|
|
|
conversions (except on Mac and Windows). Therefore, using
|
|
|
|
non-ASCII path names will mostly work even on platforms and file
|
|
|
|
systems that use legacy extended ASCII encodings. However,
|
|
|
|
repositories created on such systems will not work properly on
|
|
|
|
UTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa.
|
|
|
|
Additionally, many Git-based tools simply assume path names to
|
|
|
|
be UTF-8 and will fail to display other encodings correctly.
|
|
|
|
|
|
|
|
- Commit log messages are typically encoded in UTF-8, but other
|
|
|
|
extended ASCII encodings are also supported. This includes
|
|
|
|
ISO-8859-x, CP125x and many others, but _not_ UTF-16/32,
|
|
|
|
EBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5,
|
|
|
|
EUC-x, CP9xx etc.).
|
2006-12-30 10:22:38 +00:00
|
|
|
|
|
|
|
Although we encourage that the commit log messages are encoded
|
2013-01-21 19:17:53 +00:00
|
|
|
in UTF-8, both the core and Git Porcelain are designed not to
|
2006-12-30 10:22:38 +00:00
|
|
|
force UTF-8 on projects. If all participants of a particular
|
2013-01-21 19:17:53 +00:00
|
|
|
project find it more convenient to use legacy encodings, Git
|
2006-12-30 10:22:38 +00:00
|
|
|
does not forbid it. However, there are a few things to keep in
|
|
|
|
mind.
|
|
|
|
|
2010-01-09 23:33:00 +00:00
|
|
|
. 'git commit' and 'git commit-tree' issues
|
2008-01-03 14:18:07 +00:00
|
|
|
a warning if the commit log message given to it does not look
|
2006-12-30 10:22:38 +00:00
|
|
|
like a valid UTF-8 string, unless you explicitly say your
|
|
|
|
project uses a legacy encoding. The way to say this is to
|
2007-02-18 09:36:51 +00:00
|
|
|
have i18n.commitencoding in `.git/config` file, like this:
|
2006-12-30 10:22:38 +00:00
|
|
|
+
|
|
|
|
------------
|
2007-02-18 09:36:51 +00:00
|
|
|
[i18n]
|
2017-07-17 15:39:00 +00:00
|
|
|
commitEncoding = ISO-8859-1
|
2006-12-30 10:22:38 +00:00
|
|
|
------------
|
|
|
|
+
|
|
|
|
Commit objects created with the above setting record the value
|
2017-07-17 15:39:00 +00:00
|
|
|
of `i18n.commitEncoding` in its `encoding` header. This is to
|
2006-12-30 10:22:38 +00:00
|
|
|
help other people who look at them later. Lack of this header
|
|
|
|
implies that the commit log message is encoded in UTF-8.
|
|
|
|
|
2010-01-09 23:33:00 +00:00
|
|
|
. 'git log', 'git show', 'git blame' and friends look at the
|
2008-10-21 20:55:57 +00:00
|
|
|
`encoding` header of a commit object, and try to re-code the
|
|
|
|
log message into UTF-8 unless otherwise specified. You can
|
2006-12-30 10:22:38 +00:00
|
|
|
specify the desired output encoding with
|
2017-07-17 15:39:00 +00:00
|
|
|
`i18n.logOutputEncoding` in `.git/config` file, like this:
|
2006-12-30 10:22:38 +00:00
|
|
|
+
|
|
|
|
------------
|
2007-02-18 09:36:51 +00:00
|
|
|
[i18n]
|
2017-07-17 15:39:00 +00:00
|
|
|
logOutputEncoding = ISO-8859-1
|
2006-12-30 10:22:38 +00:00
|
|
|
------------
|
|
|
|
+
|
|
|
|
If you do not have this configuration variable, the value of
|
2017-07-17 15:39:00 +00:00
|
|
|
`i18n.commitEncoding` is used instead.
|
2006-12-30 10:22:38 +00:00
|
|
|
|
|
|
|
Note that we deliberately chose not to re-code the commit log
|
|
|
|
message when a commit is made to force UTF-8 at the commit
|
|
|
|
object level, because re-coding to UTF-8 is not necessarily a
|
|
|
|
reversible operation.
|