Git Config
Last updated
git config reads and writes Git's settings - your commit name and email, your default editor and branch name, aliases, and more. Settings live at three levels: system (all users), global (--global, your user), and local (the current repo, the default). The most common first step on a new machine is setting your name and email globally.
Try these in the terminal playground - a real shell in your browser, nothing to install.
Syntax
| Command | What it does |
|---|---|
git config --global user.name "Ada" | Set your commit name for all repos |
git config --global user.email you@x.com | Set your commit email |
git config --global init.defaultBranch main | Name new repos' first branch main |
git config --global core.editor "code --wait" | Set your default editor |
git config --list | Show all current settings |
git config user.email you@work.com | Set a repo-only value (no --global) |
The three levels
| Level | Flag | Applies to |
|---|---|---|
| System | --system | Every user on the machine |
| Global | --global | Your user, all your repos |
| Local | (default) | Just the current repository |
Git config FAQ
How do I set my name and email in Git?
Run
git config --global user.name "Your Name" and git config --global user.email "you@example.com". These identify you as the author of your commits across all your repositories. Set them once when you install Git on a new machine.What's the difference between --global and local config?
--global writes to your user-level config (~/.gitconfig) and applies to all your repositories. Omitting the flag writes to the current repository's config (.git/config), overriding the global value there only - handy for using a different email on a work repo, for example.How do I see my current Git configuration?
Run
git config --list to print all settings, or git config --list --show-origin to also see which file each value comes from. To read one value, use git config user.email. This is the quickest way to check what name and email your commits will use.How do I create a Git alias?
Use
git config --global alias.<short> "<command>", for example git config --global alias.co checkout so git co runs git checkout. Aliases are stored in your global config and save typing for commands you run often.Can I practice this online?
Yes. Open the terminal playground to run
git config in a real shell in your browser - nothing to install. Coddy's free interactive Git course also covers setting up Git step by step.