Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one change the language of the command line interface of Git?

People also ask

What is Git command line interface?

At its core, Git is a set of command line utility programs that are designed to execute on a Unix style command-line environment. Modern operating systems like Linux and macOS both include built-in Unix command line terminals. This makes Linux and macOS complementary operating systems when working with Git.

How do I use Git command line?

Open the Git command prompt window You can open the command prompt from the Actions menu on the Changes, Commits, and Branches pages. You can also open it from the Connect page: Right-click your local repo, and then click Open Command Prompt.


Add these lines to your ~/.bashrc, ~/.bash_profile or ~/.zprofile to force git to display all messages in English:

# Set Git language to English
#alias git='LANG=en_US git'
alias git='LANG=en_GB git'

The alias needs to override LC_ALL on some systems, when the environment variable LC_ALL is set, which has precedence over LANG. See the UNIX Specification - Environment Variables for further explanation.

# Set Git language to English
#alias git='LC_ALL=en_US git'
alias git='LC_ALL=en_GB git'

In case you added these lines to ~/.bashrc the alias will be defined when a new interactive shell gets started. In case you added it to ~/.bash_profile the alias will be applied when logging in.


If you just want to have one command in english instead you can just write LC_ALL=C before the command, for example:

LC_ALL=C git status

will result in

# On branch master
nothing to commit, working directory clean

The locale as used in C is English and always available without installing additional language packs
(see https://askubuntu.com/a/142814/34298)

To change it for the whole current bash session just enter

LANG=C

To change it for example to german enter

LANG=de_DE.UTF-8

Adding this line solved the problem for me: Update: it seems like more components require a Locale as well now.

$ more ~/.bash_profile

export LANG=en_US (obsolete)

export LANG="en_US.UTF-8" (Updated)


Note: since Git 2.3.1+ (Q1/Q2 2015), Git will add Accept-Language header if possible.
See commit f18604b by Yi EungJun (eungjun-yi)

Add an Accept-Language header which indicates the user's preferred languages defined by $LANGUAGE, $LC_ALL, $LC_MESSAGES and $LANG.

This gives git servers a chance to display remote error messages in the user's preferred language.


You have locale for git gui or other GUIs, but not for the command-line, considering it was one of the questions of GitSurvey 2010

localization of command-line messages (i18n)    258     3.6%    

Of course, since 2010, as po/README describes:

Before strings can be translated they first have to be marked for translation.

Git uses an internationalization interface that wraps the system's gettext library, so most of the advice in your gettext documentation (on GNU systems info gettext in a terminal) applies.

In place since git 1.7.9+ (January 2012):

Git uses gettext to translate its most common interface messages into the user's language if translations are available and the locale is appropriately set.
Distributors can drop new PO files in po/ to add new translations.

So, if your update has mess up the translation, check what gettext uses:
See, for instance, "Locale Environment Variables"

A locale is composed of several locale categories, see Aspects. When a program looks up locale dependent values, it does this according to the following environment variables, in priority order:

LANGUAGE
LC_ALL
LC_xxx, according to selected locale category: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, ...
LANG 

Variables whose value is set but is empty are ignored in this lookup.

LANG is the normal environment variable for specifying a locale. As a user, you normally set this variable (unless some of the other variables have already been set by the system, in /etc/profile or similar initialization files).

LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, and so on, are the environment variables meant to override LANG and affecting a single locale category only.
For example, assume you are a Swedish user in Spain, and you want your programs to handle numbers and dates according to Spanish conventions, and only the messages should be in Swedish. Then you could create a locale named ‘sv_ES’ or ‘sv_ES.UTF-8’ by use of the localedef program. But it is simpler, and achieves the same effect, to set the LANG variable to es_ES.UTF-8 and the LC_MESSAGES variable to sv_SE.UTF-8; these two locales come already preinstalled with the operating system.

LC_ALL is an environment variable that overrides all of these. It is typically used in scripts that run particular programs. For example, configure scripts generated by GNU autoconf use LC_ALL to make sure that the configuration tests don't operate in locale dependent ways.

Some systems, unfortunately, set LC_ALL in /etc/profile or in similar initialization files. As a user, you therefore have to unset this variable if you want to set LANG and optionally some of the other LC_xxx variables.


Run LC_MESSAGES=C git, not LC_ALL=C or LANG=C and no need delete or rename files.

This command change output Git messages to english.


GIT defaults to english if it cannot find the Locale language.

So if you want GIT to be in english, just sabotage the language file that it is running with. In my case it was always running with german (ie: de.msg).

If I deleted it or renamed the it, then it defaulted to english.

enter image description here

Here I renamed the file

enter image description here