
The git config command with the -l or --list flag can be used to display the git configurations that you have set.
When issuing the git config command without the --global flag, you must be in a directory that contains a cloned git repo and there should be a hidden .git directory. In the hidden .git directory should be a file named config. The git config command reads the .git/config file.
~]$ cd /path/to/my.repo
~]$ ls -lisa
40356964 4 drwxr-xr-x. 8 john.doe users 4096 Feb 27 06:35 .git
~]$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.com:foo/bar.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
remote = origin
merge = refs/heads/main
The git config --list command should return the same information that is in the .git/config file.
~]# git config --list
user.name="John Doe"
user.email="john.doe@example.com"
credential.https://github.com.helper=
credential.https://github.com.helper=!/home/john.doe/.local/bin/gh auth git-credential
credential.https://gist.github.com.helper=
credential.https://gist.github.com.helper=!/home/john.doe/.local/bin/gh auth git-credential
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:foo/bar.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
Likewise, the git config --global --show-origin command can be used to list the location of your global .gitconfig file.
~]$ git config --list --show-origin
file:/home/john.doe/.gitconfig user.name=John Doe
file:/home/john.doe/.gitconfig user.email=john.doe@example.com
file:/home/john.doe/.gitconfig credential.https://github.com.helper=
file:/home/john.doe/.gitconfig credential.https://github.com.helper=!/home/john.doe/.local/bin/gh auth git-credential
file:/home/john.doe/.gitconfig credential.https://gist.github.com.helper=
file:/home/john.doe/.gitconfig credential.https://gist.github.com.helper=!/home/john.doe/.local/bin/gh auth git-credential
And the global .gitconfig file should contain the same details that were returned by the above command.
~]$ cat /home/c065234/.gitconfig
[user]
name = John Doe
email = john.doe@example.com
[credential "https://github.com"]
helper =
helper = !/home/john.doe/.local/bin/gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !/home/john.doe/.local/bin/gh auth git-credential
The git config command can be used to set configuration. In this example http.proxy and https.proxy are set in the local .git/config file of the cloned repository.
git config http.proxy http://proxy.example.com
git config https.proxy https://proxy.example.com
The --global flag can be used to set the configuration in the global .gitconfig file.
git config --global http.proxy http://proxy.example.com
git config --global https.proxy https://proxy.example.com
Did you find this article helpful?
If so, consider buying me a coffee over at