When working with Git, you usually configure your user details (like name and email) globally. This means the same configuration applies to all repositories on your machine. However, there are situations where you might need different configurations for different directories.
What Does Separating Git Configurations Mean?
In Git, configurations can be applied at three levels:
- System: Configuration applies to all users and repositories on the system
- Global: Configuration applies to all repositories for the current user
- Local: Configuration applies only to a specific repository
Separating Git configurations means setting different Git settings for specific repositories or directories rather than using a single global configuration.
How to Set It Up
# Navigate to your work project
cd /path/to/work-project
# Set local config (only applies to this repo)
git config user.name "Your Work Name"
git config user.email "work-email@company.com"
# Navigate to your personal project
cd /path/to/personal-project
# Set different local config
git config user.name "Your Personal Name"
git config user.email "personal@email.com"
Conclusion
Separating Git configurations is a simple but powerful way to keep your work and personal identities separate. Use git config --local to set repo-specific settings.