Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between git config --list and cat .gitconfig?

Tags:

git

What is the difference between them both? I'm learning in my tutorial that they give out the global configuration settings, but I'm not really sure what the difference between them is, and when I should use either.

like image 916
the12 Avatar asked Dec 07 '22 21:12

the12


2 Answers

git config --list will list all configurations currently visible (in the current directory)

It will list all the configurations, system wide at the top, followed by the global configuration (most often found under ~/.gitconfig), followed by the local configurations (if inside a git repository).


cat .gitconfig will most likely only work in your home directory (~/)

Additionally the format of the two will differ.

See the documentation of git config for more details.


I don't see a reason why not to use git config --list always.

like image 97
AnimiVulpis Avatar answered Dec 11 '22 08:12

AnimiVulpis


cat .gitconfig shows you the content of the file .gitconfig. If this is the one that is used by git (this is configurable), then it is identical to the according level of settings.

In Git you have three levels of settings files, in repository, global for your user and global for the whole computer with all its users. git config --list will list all of them that are in effect in the place where you are.

like image 32
Vampire Avatar answered Dec 11 '22 08:12

Vampire