Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the qualified Git URL of a remote using url.<base>.insteadOf?

Tags:

git

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?

like image 390
David Holm Avatar asked Nov 10 '22 08:11

David Holm


1 Answers

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.

like image 148
Sascha Wolf Avatar answered Nov 15 '22 06:11

Sascha Wolf