Querying the existing configuration
In this example, we will look at how we can query the existing configuration and set the configuration values.
Getting ready
We'll use jgit
again by using the following command:
$ cd jgit
How to do it...
To view all the effective configurations for the current Git repository, run the following command:
$ git config --list user.name=Aske Olsson user.email=askeolsson@switch-gears.dk core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true remote.origin.url=https://git.eclipse.org/r/jgit/jgit remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master
The previous output will of course reflect the user running the command. Instead of Aske Olsson
as the name and the e-mail, the output should reflect your settings.
If we are just interested in a single configuration item, we can just query it by its section.key
or section.subsection.key
:
$ git config user.name...