I work with a Git repository using the url.<base>.insteadOf scheme to store the actual repo URL in my ~/.gitconfig. One of the applications I use tries to figure out the access scheme (ssh, http, etc) to the repo using git-config but it fails since the output looks something like this:
# git config --get remote.origin.url
gerrithost:department/project
Where gerrithost is set up in my ~/.gitconfig:
[url "ssh://machine.dn.tld:29418/"]
insteadOf = gerrithost:
The application expects the output of git config --get remote.origin.url to look like:
ssh://machine.dn.tld:29418/department/project
git remote -v displays the resolved URLs but I would have to parse the output to get the correct remote and field.
Is it possible to get the resolved URL using git-config (or one of the other tools) or do i have to revert to writing a parser for git remote?
As Stefan Näwe already explained in the comments, the command you are looking for is
git ls-remote --get-url
For more information take a look at the ls-remote
documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With