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

Re: How do I copy a branch & its config to a new name?

From
Jeff King <peff@peff.net>
Date
Mar 24, 2017, 21:17 UTC
Message-ID
<20170324211701.vvmp6n4c77o2dvbz@sigill.intra.peff.net>
In-Reply-To
<CACBZZX6U0PAAK8vJxBW2VSzbtfttFUNTZhDGk=BzLxkaTn64gw@mail.gmail.com>
On Fri, Mar 24, 2017 at 12:10:49PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 21 quoted lines
> Actually this is a bit confusing, but I think reversing the arguments
> makes sense, i.e.:
> 
>     git branch -c dest [src]
> 
> And similarly:
> 
>     git checkout -c dest [<src>]
> 
> This is confusing in that it reverses the arguments, but more useful
> in that it allows you to omit src like the other invocations of these
> commands, and you can e.g. do:
> 
>     git branch -c avar/topic-2
> 
> While on avar/topic to start working on avar/topic-2, which would copy
> avar/topic's state & config.
> 
> I'll put this on my TODO list, but unless someone comes up with a
> compelling argument against the above I plan to make the interface
> look like that.
I think it probably should match "git branch -m", which uses:
  git branch -c [<oldbranch>] <newbranch>

That's the closest operation we currently have, and it still allows omitting the src. It _is_ different than:

  git branch <branchname> [<start-point>]

I wondered if you could advertise "-c" not as a new "copy mode", but rather as an option for normal branch creation. Sort of a "by the way, copy the config". But I don't think that's a great mental model. <start-point> doesn't have to be a branch at all.

-Peff
Previous: Ævar Arnfjörð Bjarmason
Message 7 of 7 in “How do I copy a branch & its config to a new name?”
  1. Ævar Arnfjörð BjarmasonMar 22, 2017
  2. Jeff KingMar 22, 2017
  3. Ævar Arnfjörð BjarmasonMar 22, 2017
  4. Jeff KingMar 22, 2017
  5. Jonathan NiederMar 24, 2017
  6. Ævar Arnfjörð BjarmasonMar 24, 2017
  7. Jeff KingMar 24, 2017

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.