"Branch exists" error while trying to rename a non-existing branch to an existing one
- Date: Sun, 09 Jul 2017 23:57:39 +0530
- From: Kaartic Sivaraam <kaarticsivaraam91196@xxxxxxxxx>
- Subject: "Branch exists" error while trying to rename a non-existing branch to an existing one
I recently got the following error message by change as a result of the
$ 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
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)
* 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
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?