Config

Git - Quick Reference

3 min read

Published Jun 19 2025


7
0
0
0

CLIGit

Git has a lot of config values that your are able to set, from details of the user to the text editor used and beyond. I will not be listing all of these different options.


As a bare minimum you need to set:

  • user.name - your user name as you want it to appear on commits.
  • user.email - your email address that appears on commits. Note that anyone with access to the commits on a project will be able to view your email address used.

Config can be set at different scope levels.




Config Scopes

Config values can be set at 5 different hierarchical scopes:

  1. System : --system
    1. Applies to every user and every repository on the entire system.
    2. On Linux based systems this is stored in /etc/gitconfig.
    3. On Windows this is stored in C:\ProgramData\Git\config.
    4. It requires admin/root privileges to edit.
  2. Global : --global
    1. Applies to your user account, across all repositories you work on.
    2. On Linux based systems this is stored in ~/.gitconfig.
    3. On Windows this is stored in %USERPROFILE%\.gitconfig.
  3. Local : --local
    1. Applies to a specific repository only.
    2. This is stored in .git/config file in the project.
  4. Worktree : --worktree
    1. Applies only when using linked working trees - not common but included for completeness.
    2. This is stored in .git/worktrees/<name>/config file.
  5. Command line : -c
    1. Temporarily overriding a setting just for a specific command.

So, for example, if you have the user.name Mike Smith set at the global scope and at the local project level you have Dave Smith, Git will use the local user.name of Dave Smith. If user name isn't set at the project level then it will look up to the next level and use the global user.name of Mike Smith.

If you were then to do a commit with the -c option then this would override both the local and global user.name, eg. :

git -c user.name="Bobby Smith" commit

Git would use the name Bobby Smith just for that commit.




Listing and setting config values

List all config values at the global scope:

git config --global --list

This will display an output something like this, listing all global config values set:

user.name=Bobby
user.email=bobby@example.com
core.editor=/usr/bin/vim
core.autocrlf=false


List all config values at the local scope, when inside the projects folder:

git config --local --list

To set the user.name and user.email at the global scope:

git config --global user.name "yourname"
git config --global user.email "your@email.com"

Note you can also pass in --set with the command, but it is implied if missing. It can add clarity when using in scripts to include it though.


To get the user.name at the global scope:

git config --global --get user.name

If more than 1 key is found then it outputs the last one it finds. You can pass in --all to list all keys found.

If no scope is provided, Git looks through the hierarchy and returns the first match. Eg if the user.name is only set as global, it will check local, not find it, check global and then find a match and output it.


To remove a config setting completely:

git config --global --unset user.name

This removes the user.name from the global config file.


To show which config file a specific config is stored:

git config --show-origin --get user.name

Displays the file path of the config file and the value.


To list all config values setup on the machine:

git config --list

To list all config values setup on the machine and the config file locations:

git config --show-origin --list


Git icon

Complete config command options

For more information on all the different possible config values and config command options, which are not covered in this guide, please refer to this link.



Products from our shop

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Mug

Docker Cheat Sheet Mug

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Mug

Vim Cheat Sheet Mug

SimpleSteps.guide branded Travel Mug

SimpleSteps.guide branded Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - Black

Developer Excuse Javascript Mug - Black

SimpleSteps.guide branded stainless steel water bottle

SimpleSteps.guide branded stainless steel water bottle

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Dark

Developer Excuse Javascript Hoodie - Dark

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact