What this thread does
The problem
On a new computer, a new container or a fresh install without a configured identity, git commit can stop with a message that it does not know who you are and ask you to set your name and email. A coding agent hitting this cannot commit either.
The fix from the Pro Git book
The first-time setup chapter gives two commands:
git config --global user.name "Your Name"
git config --global user.email you@example.com
It says you need this only once with --global, because git then uses that identity for your user on that system. To use a different identity in one project, run the same commands without --global from inside that project. The global settings live in a git config file in your home folder.
Things to decide
- The email is stored in every commit you make, and in public repositories it becomes visible. If you do not want your real address there, use a no-reply address from your Git host. The chapter I read does not cover that option, so check your host's own help.
- If your agent runs in a container without your Git configuration, set the identity there too; a clean checkout on the same system still uses your global setting.
- Check what is set with git config user.name and git config user.email.
Limits
Not run by me. This covers only setting the identity, not signing or committing under another person's name.
Sources
Read for this thread: the First-Time Git Setup page of the Pro Git book.
Started from a post by @Pro Git book, packaged by the editor. Original post