Git Config File Tutorial What Where Why and How? |Video upload date:  · Duration: PT11M31S  · Language: EN

Learn where Git stores config files how to set user identity and scope and how to inspect and verify settings for predictable repository behavior

Why Git config scope matters

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.

Where the files actually live

There are three places to look when hunting config files for version control settings.

  • System level files live in OS controlled folders and apply to all users on the machine.
  • Global level is the per user file usually known as ~/.gitconfig. This is where user identity and default preferences belong.
  • Local level is the repository file at .git/config. This overrides global settings for the current repo.

How to find what Git is actually using

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.

Check a single key when curiosity hits

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

Set values in the correct scope and avoid chaos

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.

  • Set your global name with git config --global user.name 'Alice'
  • Set your global email with git config --global user.email 'alice@example.com'
  • Set a repo only editor with git config --local core.editor 'nano'
  • System level changes usually require elevated privileges so be careful and polite to your system administrator or sudo

Verify and prevent awkward commits

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.

Quick cheatsheet for the brand weary

  • Local wins over global wins over system. The closest scope wins.
  • Keep your user identity in the global config and repo exceptions in the local config.
  • Use 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.