Inside your git repository directory, run git config user.name.
Why is running this command within your git repo directory important?
If you are outside of a git repository, git config user.name gives you the value of user.name at global level. When you make a commit, the associated user name is read at local level.
Although unlikely, let's say user.name is defined as foo at global level, but bar at local level. Then, when you run git config user.name outside of the git repo directory, it gives bar. However, when you really commits something, the associated value is foo.
Git config variables can be stored in 3 different levels. Each level overrides values in the previous level.
1. System level (applied to every user on the system and all their repositories)
- to view, git config --list --system(may needsudo)
- to set, git config --system color.ui true
- to edit system config file, git config --edit --system
2. Global level (values specific personally to you, the user. )
- to view, git config --list --global
- to set, git config --global user.name xyz
- to edit global config file, git config --edit --global
3. Repository level (specific to that single repository)
- to view, git config --list --local
- to set, git config --local core.ignorecase true(--localoptional)
- to edit repository config file, git config --edit --local(--localoptional)
How to view all settings?
- Run git config --list, showing system, global, and (if inside a repository) local configs
- Run git config --list --show-origin, also shows the origin file of each config item
How to read one particular config?
- Run git config user.nameto getuser.name, for example.
- You may also specify options --system,--global,--localto read that value at a particular level.
Reference: 1.6 Getting Started - First-Time Git Setup