New machine, same existential crisis: “Who am I in Git?” Let’s fix that before your commits become anonymous mysteries.

Global configuration (all repositories)

1
2
git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Project-specific configuration (current repository only)

1
2
git config user.name "Your Name"
git config user.email "[email protected]"

Verify configuration

1
2
3
4
5
6
7
8
9
# Check global config
git config --global --list

# Check current repository config
git config --list

# Check specific value
git config user.name
git config user.email

Use case for project-specific config

Useful when you need different identities for work vs personal projects:

1
2
3
4
5
6
7
# In work repository
cd ~/work/company-repo
git config user.email "[email protected]"

# In personal repository
cd ~/personal/my-project
git config user.email "[email protected]"

Project-specific config overrides global config for that repository.