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

Re: Renaming the "master" branch without breaking existing clones

From
Jeff King <peff@peff.net>
Date
Aug 3, 2020, 21:11 UTC
Message-ID
<20200803211112.GA2720049@coredump.intra.peff.net>
In-Reply-To
<xmqq1rknv3xl.fsf@gitster.c.googlers.com>
On Mon, Aug 03, 2020 at 02:02:14PM -0700, Junio C Hamano wrote:
Show 17 quoted lines
> > There are probably some rough edges that could be smoothed (only looking
> > in refs/heads/ and using branch names instead of fully qualified refs,
> > handling the case that $to already exists more gracefully, better
> > prompting). But something like that might be useful for projects that
> > are transitioning.
> >
> > Note that it only works with protocol v2, though, because we don't
> > report non-HEAD symrefs in v0.
> 
> Renaming local branches themselves is probably the least interesting
> part.  You could even do _without_ renaming your local branches at
> all and keep working without any problem.  But you need to be able
> to adjust to the renaming upstream does, so if your 'topic' branch
> builds on top of 'refs/remotes/origin/master' and your upstream
> renames it to 'refs/remotes/origin/stuff' you'd need to reconfigure
> 'topic' branch to also build on and/or integrate with 'stuff'
> instead of 'master'.

Yeah, good point. That would be pretty easy to add to the script I showed by looking at:

  git config --get-regexp 'branch\..*\.merge' refs/heads/master

And I guess checking the matching branch.*.remote to match $remote. I think we're getting to the realm where it would be easier to implement in something besides shell. :)

But I do think a "branch renaming" helper like this might be useful for projects undergoing this rename. I don't think it makes sense to have as a first-class Git command, but I wouldn't be opposed to carrying something like it in contrib/ if somebody wanted to polish it up.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 17 in “Renaming the "master" branch without breaking existing clones”
  1. Matt McCutchenAug 3, 2020
  2. Taylor BlauAug 3, 2020
  3. Junio C HamanoAug 3, 2020
  4. Taylor BlauAug 3, 2020
  5. Jeff KingAug 3, 2020
  6. Junio C HamanoAug 3, 2020
  7. Jeff KingAug 3, 2020
  8. Junio C HamanoAug 3, 2020
  9. Jeff KingAug 3, 2020
  10. Junio C HamanoAug 3, 2020
  11. Matt McCutchenAug 4, 2020
  12. Matt McCutchenAug 4, 2020
  13. Junio C HamanoAug 3, 2020
  14. Matt McCutchenAug 3, 2020
  15. Kaartic SivaraamAug 3, 2020
  16. Junio C HamanoAug 3, 2020
  17. Kaartic SivaraamAug 4, 2020

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.