Re: [PATCH v3 0/2] remote: url-based pushRemote with renamed remotes

Ben Knoble <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
> Le 21 juil. 2026 à 16:14, Harald Nordgren via GitGitGadget <[email protected]> a écrit :
> 
> Fix git status not showing the push branch after remotes are renamed, when
> branch.<name>.pushRemote is a URL matching exactly one configured remote.
> 
> Changes in v4:
> 
> * Match against the actual push URL, including pushurl and pushInsteadOf.
> * Clarify how rearranging remotes exposes the git status tracking problem.
> * Simplify and correct the documentation for URL-valued pushRemote.
> 
> Changes in v3:
> 
> * Revamp commit messages to clarify motivation.
> 
> Changes in v2:
> 
> * Clarify that URL push destinations already work and that this change only
>   restores their tracking information.
> * Document URL values for branch.<name>.pushRemote and their @{push}
>   behavior.
> 
> Harald Nordgren (2):
>  remote: pass repository to push tracking helper
>  remote: find tracking branches for URL push destinations
> 
> Documentation/config/branch.adoc |   1 +
> Documentation/revisions.adoc     |   3 +
> remote.c                         |  43 +++++++++--
> remote.h                         |   2 +
> t/t5505-remote.sh                | 124 +++++++++++++++++++++++++++++++
> transport.c                      |   5 +-
> 6 files changed, 172 insertions(+), 6 deletions(-)
> 
> 
> base-commit: 48bbf81c29ca9a4479ec7850fe206518682cdb2f
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2358%2FHaraldNordgren%2Fremote-resolve-url-push-tracking-v3
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2358/HaraldNordgren/remote-resolve-url-push-tracking-v3
> Pull-Request: https://github.com/git/git/pull/2358
> 
> Range-diff vs v2:
> 
> 1:  b1ac49de87 = 1:  b1ac49de87 remote: pass repository to push tracking helper
> 2:  6e924a7fec ! 2:  a343af9d50 remote: find tracking branches for URL push destinations
>     @@ Metadata
>       ## Commit message ##
>          remote: find tracking branches for URL push destinations
> 
>     -    Git already accepts a repository URL as branch.<name>.pushRemote and
>     -    can push to it. When a configured remote has the same URL, however,
>     -    "git status" cannot show that remote's push branch.
>     +    Git accepts a repository URL as branch.<name>.pushRemote and can push
>     +    to it. This branch setting takes precedence over remote.pushDefault.
> 
>     -    This can happen in fork workflows when the original remote is renamed
>     -    to "upstream", the fork is added as "origin", and an existing
>     -    pushRemote value still contains the fork URL. The URL still points to
>     -    the right repository, so pushing works. However, @{push} is unavailable
>     -    because Git does not connect the URL to "origin". As a result,
>     +    A branch can be configured with a URL-valued pushRemote before any push
>     +    occurs. If the remotes are later rearranged with "git remote rename" and
>     +    "git remote add", the newly added remote may use that URL. The URL value
>     +    is unaffected by the rename and continues to take precedence over
>     +    remote.pushDefault. The URL and the remote then point to the same
>     +    repository, but Git does not connect them for tracking. Pushing works,
>     +    but @{push} cannot identify the remote's tracking branch. As a result,
>          "git status" cannot show the push branch, and an up-to-date push can
>     -    leave its local tracking information stale.
>     +    leave its tracking information stale.
> 
>     -    When exactly one configured remote has the URL as one of its
>     -    remote.<name>.url values, use its fetch refspec to find and refresh the
>     -    push branch. Keep the URL as the push destination so the configured
>     -    remote's push settings do not change existing behavior. Keep the
>     -    current behavior when no remote matches or multiple remotes match.
>     +    When exactly one configured remote uses the push destination URL, use
>     +    that remote for push tracking. Continue to push to the URL so the
>     +    configured remote's push settings do not change existing behavior. Keep
>     +    the current behavior when no remote matches or multiple remotes match.
> 
>          Signed-off-by: Harald Nordgren <[email protected]>

I find this explanation makes more sense ; it’s not how I use remote renames, since I don’t usually use URL-valued remotes, but I can see how things arise now. Thanks!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.