git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] remote: resolve URL-valued push tracking remotes

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 20, 2026, 18:49 UTC
Message-ID
<xmqq4ihtcx8g.fsf@gitster.g>
In-Reply-To
<ff645b21591a4b365b30acaf67a295510889141c.1784538618.git.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 13 quoted lines
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> A branch may name its push destination with a URL instead of a
> configured remote. This is useful in fork workflows, where the original
> remote is renamed to "upstream", the fork is added as "origin", and an
> existing branch.<name>.pushRemote continues to contain the fork URL.
>
> Git can still push through the anonymous remote created for that URL.
> However, the anonymous remote has no fetch refspec. Git therefore cannot
> resolve @{push} to origin/<branch> or update that remote-tracking branch
> after a push. The push can succeed, or report that everything is up to
> date, while status continues to compare against a stale tracking ref or
> cannot show the push branch at all.

Let me try to think aloud, rephrasing the explanation with a slightly more concrete illustration, to see whether I understand what you are trying to achieve.

The current system allows you to set:
     [branch "mytopic"]
        pushRemote = https://hosting.site/users/me/mine.git/
     [remote "notlinked"]
        url = https://hosting.site/users/me/mine.git/
        push = refs/heads/mytopic
        fetch = refs/heads/*:refs/remotes/notlinked/*

but when on the 'mytopic' branch, @{push} cannot determine which branch at the remote repository to update, so it cannot map it back to our remote-tracking branch ('refs/remotes/notlinked/mytopic' in the above illustration).

A question. Do we currently accept a string that is not a remote name as the value for 'branch.<name>.pushRemote' by design?

The 'git config --help' output explains that:
 - 'branch.<name>.pushRemote' overrides 'branch.<name>.remote' and
   'remote.pushDefault'; and
 - 'branch.<name>.remote' and 'remote.pushDefault' tell 'git fetch'
   and 'git push' which remote to work with.

It therefore seems clear that setting a string that is not a remote name (such as a URL) as the value for these three variables is a misconfiguration in the current system.

I am not saying that it should stay that way forever. But please re-read your first sentence and tell me whether it is clear that the patch extends the current system with a new feature. It was far from clear to me and caused significant confusion. Writing it like this:

    Under the current system, a branch cannot name its push
    destination using a URL.  If we were to extend the system
    to allow this, such and such benefits would become
    possible.
would have been far less confusing.
If that is what you are doing, that is.
> A uniquely matching configured remote already provides the missing
> mapping.

A very good consideration. It was the first thing that came to my mind while I was thinking aloud, constructing an illustration with 'notlinked', wondering "what if there is another remote, with the same URL, but different 'push' configuration?".

> Use its fetch refspec when resolving the push tracking branch
> and when updating tracking refs after a push.

Is this not needless, and is mentioning it not confusing? If I understand correctly, what the change entails is:

 * If the value of 'branch.<name>.pushRemote' (call it X) is 'not' a
   remote name, try to see whether there is a unique remote that
   has either (1) a 'pushurl' whose value matches X, or (2) no
   'pushurl' but a 'url' whose value matches X.  If no such remote
   exists, simply abort and refuse to proceed.
 * If there is such a remote, pretend that the value of
   'branch.<name>.pushRemote' were the name of that remote, and do
   everything else as usual.

And mapping the current branch name to its push destination via 'remote.<name>.push' to find the name of the destination branch at the remote, and then mapping it back to our remote-tracking branch using 'remote.<name>.fetch', is not something new that this topic needs to update, no?

Thanks. Once I understand what you are trying to achieve, I will offer further comments on the implementation, as I find this topic potentially quite interesting.

Previous: Harald Nordgren via GitGitGadgetNext: Harald Nordgren
Message 5 of 23 in “remote: resolve url push tracking”
  1. 0/2 remote: resolve url push trackingHarald Nordgren via GitGitGadget, Jul 20, 2026
  2. 1/2 remote: pass repository to push tracking helperHarald Nordgren via GitGitGadget, Jul 20, 2026
  3. Junio C HamanoJul 20, 2026
  4. 2/2 remote: resolve URL-valued push tracking remotesHarald Nordgren via GitGitGadget, Jul 20, 2026
  5. Junio C HamanoJul 20, 2026
  6. Harald NordgrenJul 20, 2026
  7. Junio C HamanoJul 20, 2026
  8. Junio C HamanoJul 21, 2026
  9. 0/2 remote: renamed remote push trackingHarald Nordgren via GitGitGadget, Jul 21, 2026
  10. 1/2 remote: pass repository to push tracking helperHarald Nordgren via GitGitGadget, Jul 21, 2026
  11. 2/2 remote: find tracking branches for URL push destinationsHarald Nordgren via GitGitGadget, Jul 21, 2026
  12. D. Ben KnobleJul 21, 2026
  13. Harald NordgrenJul 21, 2026
  14. 0/2 remote: url-based pushRemote with renamed remotesHarald Nordgren via GitGitGadget, Jul 21, 2026
  15. 1/2 remote: pass repository to push tracking helperHarald Nordgren via GitGitGadget, Jul 21, 2026
  16. 2/2 remote: find tracking branches for URL push destinationsHarald Nordgren via GitGitGadget, Jul 21, 2026
  17. Junio C HamanoJul 21, 2026
  18. Ben KnobleJul 22, 2026
  19. 0/2 remote: url-based pushRemote with renamed remotesHarald Nordgren via GitGitGadget, Jul 22, 2026
  20. 1/2 remote: pass repository to push tracking helperHarald Nordgren via GitGitGadget, Jul 22, 2026
  21. 2/2 remote: find tracking branches for URL push destinationsHarald Nordgren via GitGitGadget, Jul 22, 2026
  22. Junio C HamanoJul 22, 2026
  23. Junio C HamanoJul 23, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.