threads / discuss / 48241

getting pull and push URLs for the current branch

Subject: getting pull and push URLs for the current branch

## tl;dr

2 messages between Apr 8, 2018 and Apr 8, 2018.

replies: 1people: 2as markdown or json

Michal Novotny· Apr 8, 2018, 10:15 UTC · lore
Hello,

is there a way to get remote url for the current branch? That is the url that will be used when I call `git pull`. It doesn't seem to be a particularly easy task.

Thank you! clime

Ævar Arnfjörð Bjarmason· Apr 8, 2018, 11:46 UTC · re: Michal Novotny · lore

Re: getting pull and push URLs for the current branch

On Sun, Apr 08 2018, Michal Novotny wrote:
> is there a way to get remote url  for the current branch? That is the
> url that will be used when I call `git pull`. It doesn't seem to be a
> particularly easy task.
You'd do something like this (sans error checking):
    git remote get-url $(git config branch.$(git rev-parse --abbrev-ref HEAD).remote)

I.e. your HEAD may have remote tracking info set up, this'll get the remote URL for the remote it points at.

← back to recent threads