How to show Local Git Repository Configuration

Posted on

This is an article where the purpose of the writing is defined in the title of this article which is informing on how to show local git repository configuration. Showing the configuration of the existing local git repository configuration is very useful. The usage among of the other is retrieving the information of the user which is used to communicate with another say for an example a remote git repository.

Below is the command which can be performed in order to list or to display the git local repository configuration :

git config --list

Make sure that the git utility is already installed. To make sure whether the git utility has already been installed just type the command ‘git’ in the command line or terminal.

Below is the example of the output of the above command executed in the command line or terminal :

user@hostnane:~/myproject$ git config --list
user.name=Mike Rowling
user.email=mike.rowling@codeproject.com
push.default=simple
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=/home/mike/remoteproject
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.newfeature.remote=origin
branch.newfeature.merge=refs/heads/newfeature
user@hostname:~/myproject$

The above configuration output which is presented as the output generated by executing the above command can actually be retrieved from a file. The file which is storing all the configuration output of the local git repository located in the file named .git/config. But not only in the .git/config file where the command executed in the folder the output will be produced but also in the file named .gitconfig inside the home folder of a user where the user is already logged in.  So, among the other, the output of the git config –list is the combination of several git config file. Below are the configuration files which can be described :

The file config located inside the git repository folder precisely named as config where it is located in the hidden folder .git as shown below :

root@hostname:/root/myproject# tree -a -L 2
.
├── .git
│   ├── branches
│   ├── COMMIT_EDITMSG
│   ├── config
│   ├── description
│   ├── FETCH_HEAD
│   ├── HEAD
│   ├── hooks
│   ├── index
│   ├── info
│   ├── logs
│   ├── objects
│   ├── ORIG_HEAD
│   └── refs
├── notes-for-everyone
├── index.html
└── README.md

7 directories, 10 files
root@hostname:/root/myproject#

The content of the file is shown below :

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = /root/remoteproject
fetch = +refs/heads/*:refs/remotes/origin/*

Another one located in /root/.gitconfig or usually in the user home folder and it is shown as follows :

[user]
name = Mike Rowling
email = mike.rowling@codeproject.com
[push]
default = simple

Leave a Reply