Home Git Configurations - Git for Dummies, Part 03

Git Configurations - Git for Dummies, Part 03

Configure Git

Previously, we have discussed about how to install Git on various platforms. After you install Git, the next step is to configure it before it us used for the first time.

To configure Git, we use the command git config. This command can accept parameters and arguements and can set and obtain the configuration variables.

There are 3 different configuration levels in Git. They are:

  1. System (--system) - This configuration level covers an entire user, machine and all the repos in it. Changes made in this level affects the entire system and all repos in the system is affected. Editing the system level configuration is often discouraged because of this.

  2. Global (--global) - This configuration level affects the User level. This means that configuration changes will apply to all the files of the user who is currently operating the system.

  3. Repository (--local) - This configuration level only affects a specific repo (repository).

The configuration variables can be located at various places depending on your platform.

In GNU/Linux systems they are generally located in 3 different places:

  • /etc/gitconfig - stores System Level configurations.
  • ~/.gitconfig - stores Global configurations.
  • ~/<RepoFolder>/.git/config - stores Repository Level configurations.

In Windows system, they are located in:

  • C:\Documents\Git\etc\gitconfig - stores System Level configurations.
  • C:\Document and Settings\<UserName>\.gitconfig or C:\Users\<UserName>\.gitconfig - stores Global configurations.
  • C:\<RepoFolder>\.git\config - stores Repository Level configurations.

In Mac, config files are located similar to Linux:

  • /usr/local/git/etc/gitconfig - stores System Level configurations.
  • ~/.gitconfig - stores Global configurations.
  • ~/<RepoFolder>/.git/config - stores Repository Level configurations.

Configure Username and Email

After installing, the first step should be to set your username and email correctly.

To set up Git username and email use the following commands:

git config --global user.name <your name>
git config --global user.email <user@email.com> 

Please replace <your name> and <user@email.com> with your own name and email.

Configure Default Text Editor

By default, Git uses your default text editor through one of the shell environment variables VISUAL or EDITOR. Otherwise it falls back to the vi editor. However, if you wish to set one of your favorite editors as default, you need to use the core.editor setting, e.g.

git config --global core.editor editor-name
  1. To setup Sublime Text as default editor in Windows:
git config --global core.editor "'C:/Program Files/Sublime Text 2/sublime_text.exe' -n -w"

or in Mac/Linux:

git config --global core.editor "'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl' -n -w"
  1. To setup VSCode as default editor:
git config --global core.editor "code --wait"
  1. To setup Atom as default editor:
git config --global core.editor "atom --wait"

List Configurations

Once the basic configuration is in place, use the following command to check if the configurations have updated:

git config --list

The output of the above command should echo the following information:


These were the basic configurations you will need to start working with Git. However, there are several other configuration parameters that you can modify as per your requirements. You can find a full and detailed list of Git Configuration here.

That’s all for now, in the next part we will discuss how to use Git with a Local Repository.

This post is licensed under CC BY 4.0 by the author.

Git Installation - Git for Dummies, Part 02

Working with Local Repositories - Git for Dummies, Part 04

Comments powered by Disqus.