Git does not really have a concept of the "current remote". You have a current branch, and that may or may not have a remote associated with it, and may have a "pushremote" set to override the remote (in which case you'd need to change the commands below).
You can find the remote that the current branch will be pushed to (by default) using git config branch.<name>.remote
where <name>
is the name of the current branch. That will give you the name of the remote, you can get its URL with git config remote.<name>.url
, or full information about it with git remote show <name>
So if $branch
is the branch name, this will tell you the push URL:
git config remote.$(git config branch.$branch.remote).url
To handle the case where there's a pushremote
overriding the remote:
git config remote.$(git config branch.$branch.pushremote || git config branch.$branch.remote).url