Get the file location of git config values


All the configurations related to git such as the user.email and user.name are stored in the gitconfig files that can be stored at different places based on the option you provided (system, global, local) while setting them up,

  1. $PATH/etc/gitconfig: Stores the system config values, which are set using --sytem option
  2. ~/.gitconfig: Stores the personal/global values which are set using --global option.
  3. .git/config: Stores values at the local repository level, set using the --local option.

You can see all the config values using the command: git config -l or git config --list

Example:
% git config -l

user.env=uat
user.email=you@example.com
user.name=Code2care
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
user.team=dev

In order to see the file location of all the config values add the option --show-origin

Example:
git config --list --show-origin 

file:/etc/gitconfig     user.env=uat
file:/root/.gitconfig   user.email=you@example.com
file:/root/.gitconfig   user.name=Code2care
file:.git/config        core.repositoryformatversion=0
file:.git/config        core.filemode=true
file:.git/config        core.bare=false
file:.git/config        core.logallrefupdates=true
file:.git/config        user.team=dev
file location git config values
Advertisements
Try Out Code2care Dev Tools:

Advertisements

Advertisements
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.