From: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Harald Nordgren <haraldnordgren@gmail.com>
Subject: [PATCH v2 0/2] remote: renamed remote push tracking
Date: Tue, 21 Jul 2026 08:58:24 +0000 [thread overview]
Message-ID: <pull.2358.v2.git.git.1784624306.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2358.git.git.1784538618.gitgitgadget@gmail.com>
Keep git status showing the push branch after remotes are renamed by finding
the configured remote with the same URL.
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 | 2 +
Documentation/revisions.adoc | 3 +
remote.c | 36 +++++++++--
remote.h | 2 +
t/t5505-remote.sh | 104 +++++++++++++++++++++++++++++++
transport.c | 5 +-
6 files changed, 146 insertions(+), 6 deletions(-)
base-commit: 48bbf81c29ca9a4479ec7850fe206518682cdb2f
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2358%2FHaraldNordgren%2Fremote-resolve-url-push-tracking-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2358/HaraldNordgren/remote-resolve-url-push-tracking-v2
Pull-Request: https://github.com/git/git/pull/2358
Range-diff vs v1:
1: fc70895732 ! 1: b1ac49de87 remote: pass repository to push tracking helper
@@ Metadata
## Commit message ##
remote: pass repository to push tracking helper
- The push tracking helper currently only needs the push remote. However,
- resolving a URL-valued remote requires access to the repository's list
- of configured remotes.
+ The next commit needs tracking_for_push_dest() to inspect the
+ repository's configured remotes. Pass the repository through the
+ existing callers and mark the new parameter as unused.
- Pass the repository through the existing callers and mark the parameter
- as unused for now. This prepares the helper for that lookup without
- changing its behavior.
+ No change in behavior.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
2: ff645b2159 ! 2: 6e924a7fec remote: resolve URL-valued push tracking remotes
@@ Metadata
Author: Harald Nordgren <haraldnordgren@gmail.com>
## Commit message ##
- remote: resolve URL-valued push tracking remotes
+ remote: find tracking branches for URL push destinations
- 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 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 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.
+ 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,
+ "git status" cannot show the push branch, and an up-to-date push can
+ leave its local tracking information stale.
- A uniquely matching configured remote already provides the missing
- mapping. Use its fetch refspec when resolving the push tracking branch
- and when updating tracking refs after a push. This changes neither the
- push destination nor configuration. Keep the existing behavior when no
- remote matches or multiple remotes share the URL, since either case is
- ambiguous.
+ 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.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
+ ## Documentation/config/branch.adoc ##
+@@ Documentation/config/branch.adoc: This option defaults to `never`.
+ repository), you would want to set `remote.pushDefault` to
+ specify the remote to push to for all branches, and use this
+ option to override it for a specific branch.
++ The value may be the name of a configured remote or a repository
++ URL. A URL is used directly as the push destination.
+
+ `branch.<name>.merge`::
+ Defines, together with `branch.<name>.remote`, the upstream branch
+
## Documentation/revisions.adoc ##
@@ Documentation/revisions.adoc: some output processing may assume ref names in UTF-8.
`git push` were run while `branchname` was checked out (or the current
`HEAD` if no branchname is specified). Like for '@\{upstream\}', we report
the remote-tracking branch that corresponds to that branch at the remote.
-+ If the push remote is specified as a URL, the fetch refspec of a uniquely
-+ matching configured remote is used to find and update the remote-tracking
-+ branch.
++ If the push destination is a URL and exactly one configured remote has the
++ same `remote.<name>.url`, '@\{push}' reports the remote-tracking branch for
++ that remote.
+
Here's an example to make it more clear:
+
--
gitgitgadget
next prev parent reply other threads:[~2026-07-21 8:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 9:10 [PATCH 0/2] remote: resolve url push tracking Harald Nordgren via GitGitGadget
2026-07-20 9:10 ` [PATCH 1/2] remote: pass repository to push tracking helper Harald Nordgren via GitGitGadget
2026-07-20 18:23 ` Junio C Hamano
2026-07-20 9:10 ` [PATCH 2/2] remote: resolve URL-valued push tracking remotes Harald Nordgren via GitGitGadget
2026-07-20 18:49 ` Junio C Hamano
2026-07-20 19:56 ` Harald Nordgren
2026-07-20 23:49 ` Junio C Hamano
2026-07-21 16:11 ` Junio C Hamano
2026-07-21 8:58 ` Harald Nordgren via GitGitGadget [this message]
2026-07-21 8:58 ` [PATCH v2 1/2] remote: pass repository to push tracking helper Harald Nordgren via GitGitGadget
2026-07-21 8:58 ` [PATCH v2 2/2] remote: find tracking branches for URL push destinations Harald Nordgren via GitGitGadget
2026-07-21 14:28 ` [PATCH v2 0/2] remote: renamed remote push tracking D. Ben Knoble
2026-07-21 20:10 ` Harald Nordgren
2026-07-21 20:14 ` [PATCH v3 0/2] remote: url-based pushRemote with renamed remotes Harald Nordgren via GitGitGadget
2026-07-21 20:14 ` [PATCH v3 1/2] remote: pass repository to push tracking helper Harald Nordgren via GitGitGadget
2026-07-21 20:14 ` [PATCH v3 2/2] remote: find tracking branches for URL push destinations Harald Nordgren via GitGitGadget
2026-07-21 22:15 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.2358.v2.git.git.1784624306.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=haraldnordgren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.