How to use JGit to get the source url?

How to use JGit to get the remote source url ?

I am using JGit and I want to execute

git config --get remote.origin.url

How to do it?

+9
source share
1 answer

Git repository configuration can be accessed via Repository::getConfig(). Return Type - StoredConfig.

To get the remote source url use this snippet

String url = repository.getConfig().getString("remote", "origin", "url");

The class ConfigConstantslists a set of commonly used section names and value names.

+12
source

All Articles