Quick Tip: Git, Mac OS X and German Umlauts (Umlaute)
»Git«
Quick Tip, Git, Mac OS X, Umlauts, Umlaute, UTF-8, Unicode
Update from September 22, 2015
In the current version of Mac OS X (10.10.5) with the latest version of Git (2.5.2) precomposeunicode
has to be set to true
[core]
# Git and the Umlaut problem on Mac OS X
# Prevent showing files which filenames contains umlauts as untracked
# Needs to be `false` since OS X 10.9.x
precomposeunicode = true
Sure, using umlauts or other special characters within filenames is far from being called a best practice and should be forbidden by law (or at least by convention) for source code repositories. But sometimes you just have to deal with given files and might wonder why you find untracked files in a freshly cloned Git repository. If you’re on Mac OS X there is a great chance that this is caused by Umlauts or other Unicode characters.
In a Git client like SourceTree or Tower the filenames (of the suprisingly untracked files) look like your expect them to look:
If you fire git status
in your Terminal instead you see how Git handles Unicode characters:
That’s easy to fix … but in a different way depending on your OS X version (See: stackoverflow.com)
Since OS X 10.9.x precomposeunicode
has to be set to false
. This should be defined in your global .gitconfig
and if needed within your repository as well.
Global
You can choose whether to add the following to ~/.gitconfig
via your file system:
[core]
# Git and the Umlaut problem on Mac OS X
# Prevent showing files which filenames contains umlauts as untracked
# Needs to be `false` since OS X 10.9.x
precomposeunicode = false
See my dotfiles.
Or via your Terminal:
git config --global core.precomposeunicode false
In your repository
This seems to be necessary depending on how the repository was created.
In addition to both ways described globally you can also edit the .gitconfig
of your repository via the SourceTree user interface. Just click the following within the programs menu: »Repository« → »Repository Settings« → »Edit Config File …« and add precomposeunicode = false
below [core]
as described above.
Or via the Terminal just like before but without the global flag:
cd ~/my/path/to/repository
git config core.precomposeunicode false
Please note: There’s no need to trash the repository and clone it a second time. Just apply the settings and you’re good to go
Related posts
- How to flash ESP8266 (and ESP32) to use Espruino firmware on macOS
- Helpers and tips for npm run scripts
- JSConf Budapest 2017 – A personal recap
Comments
Comments are removed for now. Feel free to contact me via Twitter in case you’d like to talk about this blog post: @mkuehnel.