Git Config: Set Your Name, Email, and Branch Defaults
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:
| Scope | File | What it affects |
|---|---|---|
| system | /etc/gitconfig | All users on the machine |
| global | ~/.gitconfig | All repos for one user |
| local | .git/config | One repository |
| worktree | .git/config.worktree | Part 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.

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
Git Branching: Create, Switch, and Manage Branches
Mar 31, 2026 by ThePrimeagen - Ex-Netflix engineer, NeoVim ricer, and Git rebaser
A Git branch allows you to keep track of different changes separately. For example, you can create a new branch to experiment with changing a color scheme without affecting your primary branch. If you like the changes, you merge (or rebase) the branch back into main. If you don’t, you delete it.
Git Internals: How Git Stores Data and History on Disk
Mar 31, 2026 by ThePrimeagen - Ex-Netflix engineer, NeoVim ricer, and Git rebaser
Let’s take a look at some of git’s “plumbing”, that is, the commands that are mostly used for working “under-the-hood” with Git, and that you’ll only use if you’re trying to debug your Git files themselves.
Git Merge: Combine Branches and Understand Fast-Forwards
Mar 31, 2026 by ThePrimeagen - Ex-Netflix engineer, NeoVim ricer, and Git rebaser
“What’s the point of having multiple branches?” you might ask. They’re most often used to safely make changes without affecting your (or your team’s) primary branch. Once you’re happy with your changes, you’ll want to merge them back into main so that they make their way into the final product.
Git for Beginners: Install It and Make Your First Commit
Mar 31, 2026 by ThePrimeagen - Ex-Netflix engineer, NeoVim ricer, and Git rebaser
Git is the distributed version control system (VCS). Nearly every developer in the world uses it to manage their code. It has quite a monopoly on VCS. Developers use Git to: