How to use JGit to get the URL of the origin remote?
I am using JGit and I want to execute
git config --get remote.origin.url
How to do that?
How to use JGit to get the URL of the origin remote?
I am using JGit and I want to execute
git config --get remote.origin.url
How to do that?
The configuration of a git repository can be accessed through Repository::getConfig()
. The returned type is a StoredConfig
.
In order to get the URL of the origin remote, use this snippet
String url = repository.getConfig().getString("remote", "origin", "url");
The class ConfigConstants
lists a set of frequently used section names and value names.