How to configure git encoding for German Umlaute on Ubuntu and Windows?
I noticed that commit messages that contain German Umlaute are not displayed correctly when I run git log
in Git Bash on Windows. Those commits were made on Ubuntu using the Terminal. Normally, commit messages are written in English but when it comes to names there is no way around, e.g. Added library by Simon Jünker.
I guess it can also be Git Bash which cannot handle the character encoding. But maybe there is a setting to force utf-8
encoding for wr开发者_高级运维iting and displaying text in any module (Git Gui, Git k) of Git.
What is your multi-platform character encoding setup for Git? Please, make sure to include the configuration for both platforms in your answer. You can also add MacOS.
This link showed the way to solve this issue:
Please try:
set LESSCHARSET=UTF-8
in the Windows command Shell (cmd.exe) and run the git commands again.
Try to set git config on GIT Bash prompt with one of the following commands:
git config --global i18n.commitEncoding utf8
git config --global i18n.commitEncoding cp1252
If somone in your team uses another encoding, you will have a missmatch. Petra uses utf8:
git commit -m "Petras message with umlaut ÄäÜüÖöß etc."
Karl uses cp1252:
git commit -m "Karls message with umlaut ÄäÜüÖöß etc."
Sara checks out the pushed branch and depending on her encoding she will see one of the messages wellformed and the other missformed.
git config --global i18n.commitEncoding utf8
git log -n 2 --oneline
Petras message with umlaut ÄäÜüÖöß etc.
Karls message with umlaut <C4><E4><D6><F6><DC><FC><DF> etc.
git config --global i18n.commitEncoding cp1252
git log -n 2 --oneline
Petras message with umlaut ÄäÜüÖöß etc.
Karls message with umlaut ÄäÜüÖöß etc.
On Mac OS X things should work fine with the built-in terminal as long as you have the encoding set in Preferences > Settings > Advanced and you’ve selected “Set locale environment variables on startup.” (These are the defaults.)
Apparently MSysGit on Windows doesn’t support UTF-8, but if you pipe git command output through a copy of less
from cygwin things will work. There’s some useful info in the msysgit Google Group.
精彩评论