Git has opinions about who you are and how you work. Those opinions live in config files that can be global to your user, local to a repo, or system wide for everyone on the machine. If you do not understand scope you will get awkward commit signatures, editor wars, and the kind of surprises that make you blame your keyboard instead of your configuration.
There are three places to look when hunting config files for version control settings.
~/.gitconfig
. This is where user identity and default preferences belong..git/config
. This overrides global settings for the current repo.When you want truth and not guesses, run this little truth machine.
git config --list --show-origin
This prints every active variable and shows the file it came from. It is the polite way to avoid blaming coworkers when the author name is wrong.
To read the value for a specific key use the key name. For example run
git config user.email
From inside a repository this returns the repository scoped value if one exists. Add the --global
flag to read the user level like this
git config --global user.email
Be intentional. Set identity at the global level so your commits do not wander around with mystery names. Set repository specific overrides at the local level for projects that need a different identity or special settings.
git config --global user.name 'Alice'
git config --global user.email 'alice@example.com'
git config --local core.editor 'nano'
After any change run the show origin listing again to confirm which file provided which value. The commit machinery reads the effective configuration so verification prevents awkward commit signatures and surprise diffs.
git config --list --show-origin
for a full audit.This is not rocket science, it is just file housekeeping for your dotfiles. Treat your configs like the tiny dictatorial overlords they are. Set them thoughtfully and your commits will finally behave.
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.