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

Re: "Branch exists" error while trying to rename a non-existing branch to an existing one

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 9, 2017, 18:57 UTC
Message-ID
<xmqqd1998mks.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1499624859.8552.9.camel@gmail.com>
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:
Show 9 quoted lines
> I recently got the following error message by change as a result of the
> command,
>
>     $ git branch -m no-branch master
>     fatal: A branch named 'master' already exists.
>
> Note: no-branch is an hypothetical branch that doesn't exist.
>
> Shouldn't I get a 'no-branch' doesn't exist before that?

This is borderline "meh" at least to me. An argument against a hypothetical version of Git that "fixes" your issue would be that no matter what the source of renaming is, as long as 'master' exists, "branch -m" shouldn't overwrite it, and it is a good thing to remind the user that 'master' exists and the user meant to rename it to something else.

Of course you can make the error message three-way, but I do not think it is worth it.

Previous: Kaartic SivaraamNext: Kaartic Sivaraam
Message 2 of 3 in “"Branch exists" error while trying to rename a non-existing branch to an existing one”
  1. Kaartic SivaraamJul 9, 2017
  2. Junio C HamanoJul 9, 2017
  3. Kaartic SivaraamJul 10, 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.