Git configurations are stored in three different places
- System – System wide git configuration generally stored in /etc/gitconfig file, affects all git repository in the system.
- Global – User wide git configuration generally stored in ~/.git/config file, affects all git repository of current user.
- Local – Local git configuration generally stored in <git_repo>/.git/config file, affects current git repository only.
Get git system configuration details:
1 2 3 4 |
## Get git system configuration details git config --system --list #or sudo cat /etc/gitconfig |
Get git global configuration details:
1 2 3 4 |
## Get git global configuration details git config --global --list #or cat ~/.git/config |
Get git local configuration details:
1 2 3 4 |
## Get git local configuration details git config --local --list #or cat |
Get all git configuration details:
1 2 |
## Get all git configuration details git config --list |
Get a specific git configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
## Create a new git repository git init mydir && cd mydir ## Add a new configuration in git config file git config --add --local user.email cloudaffaire@gmail.com git config --add --local user.name cloudaffaire ## Get a specific git configuration git config --local --get user.name git config --local --get-all user.name git config --local --get-regexp "user*" cd .. && rm -rf mydir |