Git stores configuration in three scopes that you should know about if you enjoy understanding why your commits look like they belong to someone else. The scopes are system global and local. The system file applies to every user on the machine and is usually at /etc/gitconfig
. The per user global file lives at ~/.gitconfig
or in modern setups at ~/.config/git/config
. The repo specific local file is at .git/config
inside the project folder.
Before you start panicking about mysterious settings run the built in detective command
git config --show-origin --list
This prints each config key along with the exact file path that defined it. It will save you from a lot of blind guessing and blame assigning.
Config precedence goes local then global then system so a value in .git/config
overrides the same key in ~/.gitconfig
. That is why your name or email can still be wrong for a single repo even though you set it globally.
git config --global user.name YourName
git config user.email
git config --show-origin --list
to see the source file for each key.git/config
to inspect overridesGIT_DIR
variable or other core environment variables that can redirect which config is used/etc/gitconfig
can be set by admins for all usersIf your commits show the wrong author on GitHub or you have odd behavior in your version control workflow the config location and precedence are usually the culprit. Fix the right file and the problem goes away. If it does not then you probably missed an environment override or a repo specific setting.
When in doubt run git config --show-origin --list
first. It tells you where to look and saves you from guessing which config file is haunting your repo. Now go fix the config and pretend this was all part of a planned refactor.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.