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

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

From
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Date
Jul 9, 2017, 18:27 UTC
Message-ID
<1499624859.8552.9.camel@gmail.com>
Hello all,

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? Wouldn't this behaviour make the users search for the non-existing 'no-branch' in their repo?

I tried digging the implementation a little and what I could interpret from it is,

    * only the validity of new branch name (master, in the above case)
    is checked
    * checking for existence of the branch being renamed(no-branch) is
    not done at all. It seems to be left to the lower level commands to
    identify.

I'm puzzled by seeing this. Why isn't there any check for the existence of the branch being renamed and warning the user about that first?

-- 
Kaartic
Next: Junio C Hamano
Message 1 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.