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

Re: renaming remote branches

From
Jeff King <peff@peff.net>
Date
Apr 16, 2009, 13:50 UTC
Message-ID
<20090416135037.GA7770@coredump.intra.peff.net>
In-Reply-To
<76718490904160609s1ef9c1e0m6f19ff169666fa3@mail.gmail.com>
On Thu, Apr 16, 2009 at 09:09:17AM -0400, Jay Soffian wrote:
Show 7 quoted lines
> On Thu, Apr 16, 2009 at 2:59 AM, Jeff King <peff@peff.net> wrote:
> > Not only is this not user-friendly, but it does not preserve any branch
> > config or reflog at the remote (both things that "branch -m" does).
> 
> I wonder whether we should:
> 
> a) teach git remote a rename-branch sub-command

I think that is a reasonable place for such a helper command to go, whether it is tightly integrated with git or not (IOW, even with nothing else, it might still be useful to have a wrapper to parse the remote hostname and directory from the config, ssh in, and run "git branch -m").

> b) add support on the remote side for properly preserving the config and reflog

Do you mean over the git protocol? I don't see a real reason not to have it (since we allow deletion already, the user is not doing anything more destructive than what we already do). But I think any proposal would have to spell out how the protocol could accomodate this in a backwards-compatible manner.

I wonder if we could simply do "rename detection" on the list of pushed refs, and save the config and reflog in that case. IOW, detect

  git push remote remote/foo:refs/heads/bar :refs/heads/foo

I think there is fundamentally a race condition with the "create new and delete old" approach, though, as nothing is guaranteeing that your "new" and the remote's "old" have the same thing in them. You might be deleting somebody else's new commits, no "--force" required. So probably it is better to be able to explicitly specify a rename.

All of that is assuming that remote renames are common enough to really care about. Personally, I've never actually done one.

-Peff
Previous: Jay SoffianNext: Miles Bader
Message 6 of 9 in “renaming remote branches”
  1. Miles BaderApr 16, 2009
  2. Jeff KingApr 16, 2009
  3. Miles BaderApr 16, 2009
  4. Jeff KingApr 16, 2009
  5. Jay SoffianApr 16, 2009
  6. Jeff KingApr 16, 2009
  7. Miles BaderApr 17, 2009
  8. Jeff KingApr 17, 2009
  9. Dmitry PotapovApr 17, 2009

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.