31

My ˋgitˋ is in german, it says:

ˋAuf Zweig masterˋ

instead of

On branch master

with git status.

What's the reason for this?

Timo
  • 2,922
  • 3
  • 29
  • 28
kadrian
  • 4,761
  • 8
  • 39
  • 61

6 Answers6

45

Probably you locale is german. You can see it by locale. Try to change it by: export LANG="en_US.UTF-8"

Aleksey Bakin
  • 1,506
  • 13
  • 27
23

The reason for this is that your command line language is set to German. So when you do:

echo $LANG

you will see:

de_DE.UTF-8

To change this, do:

echo "export LANG=en_US.UTF-8" >> ~/.bashrc

assuming your standard shell is bash.

Don't forget:

source ~/.bashrc
Karsten S.
  • 2,349
  • 16
  • 32
kadrian
  • 4,761
  • 8
  • 39
  • 61
12

Sometimes changing the LANG environment variable alone is not good enough.

You may also need to add LC_ALL

export LC_ALL=en_US.UTF-8

According to The IEEE and The Open Group - Environment Variables.

It is because the environment variables starting by LC_* will be used first by your system before LANG:

The values of locale categories shall be determined by a precedence order; the first condition met below determines the value:

  1. If the LC_ALL environment variable is defined and is not null, the value of LC_ALL shall be used.

  2. If the LC_* environment variable (LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME) is defined and is not null, the value of the environment variable shall be used to initialize the category that corresponds to the environment variable.

  3. If the LANG environment variable is defined and is not null, the value of the LANG environment variable shall be used.

  4. If the LANG environment variable is not set or is set to the empty string, the implementation-defined default locale shall be used.

To change it permanently, you need to paste the code above into your favourite shell configuration file (probably ~/.bashrc or ~/.zshrc)

Then to apply the modification do:

$ source ~/.bashrc

or

$ source ~/.zshrc

Otherwise, just open a new terminal.

Kruupös
  • 5,097
  • 3
  • 27
  • 43
10

In my case, setting LANG or LC_ALL was not enough. I also had a LANGUAGE environment variable which was set to en_GB:en_US:de. Despite the ordering, which is presumably an order of preference, it resulted in a German language response from git and other commandline-programmes. When I changed it to en_GB:en_US, git and other programmes became English.

gerrit
  • 24,025
  • 17
  • 97
  • 170
1

As explain in @Tom comment, it is possible to add alias. In my case, I add in my Ubuntu ~/.bash_aliases

alias giten='LANGUAGE=en_GB:en_Us git'
# setup autocompletion
if [ -f "/usr/share/bash-completion/completions/git" ]; then
  source /usr/share/bash-completion/completions/git
  __git_complete giten _git_main
else
  echo "Error loading git completions"
fi

so if I use git, it is in my language, if I use giten, it is in english

NOTA: the auto-completion is lost if you don't add if … completion

bcag2
  • 1,988
  • 1
  • 17
  • 31
1

Referring to the answer by bcag2: I like this answer, because it changes language for git, and it leaves the system setting intact.
Actually I cannot imagine you all don't have the "g" alias for git, and the completions will still work if you do it like this:

alias g="LANGUAGE=en_GB:en_Us git"

# setup autocompletion 
if [ -f "/usr/share/bash-completion/completions/git" ]; then
   source /usr/share/bash-completion/completions/git
   __git_complete g _git_main
else
   echo "Error loading git completions"
fi
Filip Stachowiak
  • 376
  • 1
  • 5
  • 13
  • In my case under ubuntu 22.04, your setting returns me `__git_complete : command not found`. I replace by ```# setup autocompletion if [ -f "/usr/share/bash-completion/completions/git" ]; then source /usr/share/bash-completion/completions/git __git_complete g _git_main else echo "Error loading git completions" fi``` (https://stackoverflow.com/questions/9869227/git-autocomplete-in-bash-aliases) – bcag2 Jun 20 '23 at 13:17
  • Right, I assumed the autocompletions already configured. I added your safe autocompletion setup to the answer. Thanks! – Filip Stachowiak Jun 21 '23 at 07:03