Git Config: Set Your Name, Email, and Branch Defaults

Boot.dev Blog » DevOps » Git Config: Set Your Name, Email, and Branch Defaults
ThePrimeagen
ThePrimeagen Ex-Netflix engineer, NeoVim ricer, and Git rebaser

Last published March 31, 2026

Table of Contents

Git stores author information so that when you’re making a commit it can track who made the change. Here’s how all that configuration actually works.

All the content from our Boot.dev courses are available for free here on the blog. This one is the “Config” chapter of Learn Git. If you want to try the far more immersive version of the course, do check it out!

How Do You Set Your Name and Email?

To update your name and email in your Git configuration:

git config set --global user.name "ThePrimeagen"
git config set --global user.email "[email protected]"

Let’s pick the command apart:

  • git config: The command to interact with your Git configuration.
  • set: The subcommand to set a value — add it if it doesn’t already exist, or update it if it does.
  • --global: Store this configuration globally in your ~/.gitconfig. The opposite is --local, which stores the configuration in the current repository only.
  • user: The section.
  • name: The key within the section.
  • "ThePrimeagen": The value you want to set for the key.

You can actually store any old data in your Git configuration. Granted, only certain keys are used by Git, but you can store whatever you want:

git config set webflyx.ceo "ThePrimeagen"
git config set webflyx.valuation "mid"
git config list --local

You can also just view the contents of your local config file directly:

cat .git/config

How Do You Read a Single Config Value?

The list command lets you see all the configuration values, but the get subcommand is useful for getting a single value:

git config get <key>

Keys are in the format <section>.<keyname>. For example, user.name or webflyx.ceo.

How Do You Remove a Config Value?

The unset subcommand is used to remove a configuration value:

git config unset webflyx.cto

Note that unset only removes a single key. It can’t remove an entire section — that’s a separate operation.

How Do You Remove an Entire Config Section?

While we can store any key/value pairs we want in our Git configuration, that doesn’t mean we should. The remove-section subcommand wipes an entire section:

git config remove-section webflyx

Why Does Git Allow Duplicate Keys?

Typically, in a key/value store, like a Python dictionary, you aren’t allowed to have duplicate keys. Strangely enough, Git doesn’t care.

git config set --append webflyx.ceo "Warren"
git config set --append webflyx.ceo "Carson"
git config set --append webflyx.ceo "Sarah"
git config list --local

[!warning] Youn probably shouldn’t actually do this…

And beware, unset by itself only removes one instance. If you want to purge all instances of a key, use unset --all:

git config unset --all webflyx.ceo

Where Does Git Store Configuration?

There are several locations where Git can be configured. From more general to more specific, they are:

ScopeFileWhat it affects
system/etc/gitconfigAll users on the machine
global~/.gitconfigAll repos for one user
local.git/configOne repository
worktree.git/config.worktreePart of one repo

In my experience, 90% of the time you’ll be using --global to set things like your username and email. The other 9% of the time you will be using --local to set project-specific configurations. The last 1% of the time you might need to futz with system and worktree configurations, but it’s extremely rare.

If you set a configuration in a more specific location, it will override the same configuration in a more general location. For example, if you set user.name in the local configuration, it will override the user.name set in the global configuration.

overriding

Frequently Asked Questions

What does git config do?

git config reads and writes Git configuration values. You use it to set your identity, defaults, and other settings that change how Git behaves.


What is the difference between global and local Git config?

Global config applies to all of your repositories. Local config applies only to the current repository. If both are set, the local value wins.


How do I see my Git config values?

Use git config list to print them all, or git config get to read one value at a time. The local config file lives at .git/config.


How do I remove a Git config value?

Use git config unset for a single value, or git config unset --all to remove every instance of a duplicated key.


Can Git config have duplicate keys?

Yes. Strangely enough, Git doesn't care. You can append the same key multiple times. Use unset --all to purge all instances.

Related Articles