git config: name, email, and settings
Updated July 31, 2026
git config stores git settings: the name and email that sign every commit, the editor for commit messages, and every other key.
Set the name and email once, right after installing git. That signature stays visible in the history to everyone who opens it, so use the name your colleagues know you by.
$ git config --global user.name "Anna Petrova"
$ git config --global user.email "anna@example.com"The quotes are there because the name contains a space. The email does not have to be a working one, but use the address tied to your GitHub account: that is how the site links commits to your profile.
Three levels of settings
The --global flag means "for all my repositories on this machine". Those keys go into ~/.gitconfig in your home directory. Without the flag, git config writes to .git/config inside the current repository, and the local entry wins over the global one. That is how you give one project a work email and keep the personal one everywhere else.
$ git config user.email "anna@company.com" # this repository only
$ git config --get user.email
anna@company.comThere is a third level, the system one (--system), shared by every user of the machine. You almost never touch it.
See what is set
$ git config --global --list
user.name=Anna Petrova
user.email=anna@example.com
core.editor=nanogit config --list --show-origin adds the file each line came from. It is the fastest way to find out why your commits are signed with something you did not expect.
~/.gitconfig is a plain text file. You can read it and edit it by hand:
$ cat ~/.gitconfig
[user]
name = Anna Petrova
email = anna@example.comThe editor git opens for a commit message comes from the core.editor key. On many systems the default is vim, and getting out of it is hard the first time. Set the one you actually use:
$ git config --global core.editor nanoCommon mistakes
A missing identity shows up on your very first commit. Git falls back to your system username and hostname, signs the snapshot with something like anna@MacBook-Air.local, and prints a warning telling you to run git config --global --edit. The signature of the last commit is fixed with git commit --amend --reset-author.
The second mistake is setting the email without --global while standing in the wrong directory. The setting lands in one repository, and every other one keeps the old value. Check the result with git config --list --show-origin.
Where this is in the book
The topic is covered in Chapter 2. Your first repository.
To practise it by hand, take the interactive lesson Your first repository.