Git provides different configurations like username, email, preferred text editor, etc. These configurations can be set in different levels where they are used according to their levels. The
Global Git Configuration is used globally where it affects all git repositories unless there is a local or repository-based configuration. In this tutorial, we examine how to configure git globally.
Git Global Config File
The global git configuration is stored in a file named
.gitconfig . This file contains configurations line by line and is stored in different paths for different operating systems. The USERNAME is the current user’s username.
How To Set Global Git Configurations
git config command is used to set or change git configurations. The
--global option is added to the “git config” file.
$ git config --global user.name "İsmail Baydan" $ git config --global user.email "email@example.com" $ git config --global core.editor "vim"
How To Set Global Username
We can set the user name globally by using the
user.name option. In the following example, we set the global user name as “İsmail Baydan”.
$ git config --global user.name "İsmail Baydan"
How To Set Global Email
In the following example, we set the global email configuration as “firstname.lastname@example.org”.
$ git config --global user.email "email@example.com"
How To Set Global Text Editor
Some git operations like creating a commit, adding comments, etc. require a text editor which is generally used via the command-line interface. Even though git uses the default system text editor we can also specify another editor globally.
$ git config --global core.editor "vim"