Who is admin@MacBook-Pro.local?
That's roughly what a commit author can look like before Git is configured. GitHub won't be able to link such a commit to your profile, and the project history won't make it quite clear who made it. It's easy to fix: two commands — and every commit you make is signed with your name.
Goal
Configure Git and create or clone a repository.
Key concepts
- Configuration levels:
--system,--global,--local user.nameanduser.emailare written into every commitgit initcreates a new repositorygit clonecopies an existing one along with its history
Commands / artifacts
git config --global user.name "Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git init
git clone <url>
Common mistakes
| Symptom | Cause | Fix |
|---|---|---|
| Commits with someone else's or an empty author | user.name / user.email not set | configure them with --global, or --local for a project |
Practice
Set your name and email, create a repository with git init, and clone any public repository.
Interview Questions
git init creates a new empty repository in the current folder. git clone <url> copies an existing repository with its entire history and branches and sets up the origin remote right away.
At three levels: --system — for all users on the machine (/etc/gitconfig), --global — for your user (~/.gitconfig), --local — for one repository (.git/config). The closer level overrides the farther one: local → global → system. To see everything with its source: git config --list --show-origin.