As a popular source code management system Git provides different configurations. The current developer username is one of the most popular configurations. If the Username is not set for a repository we can not commit. The Username can be set in different modes like repository level, user level, global level, etc. If we set the Username globally or global username. This will be used by all repositories created by the user.
Set Global Username Using “git config” Command
git config command can be used to set a global username. The
--global parameter is added to the “git config” command with the
user.name configuration. In the following example, we configure the global user name as “İsmail Baydan”. The username should be a string and can be provided inside double quotes like below.
$ git config --global username "İsmail Baydan"
Set Global Username Using Git Configuration File
The Git configurations are stored inside text files in different locations for different operating systems. We can set the glocal username using the git configuration file.
Linux (Ubuntu, Fedora, CentOS, etc.):
For Linux distributions, the global git config is stored inside the
~/.giconfig file which is located under the current user home directory. Just open this file with your favorite editor and add or change the following lines to set a new username.
[user] name="İsmail Baydan"
For Windows operating systems the global git configuration file is stored
C:\Users\username\.gitconfig where the
username is the current user’s home directory or username. Just open this file with your favorite text editor and put the following lines to set the global username for git.