Answer the question
In order to leave comments, you need to log in
Preventing me from creating a new git branch?
I created a new branch, made a commit in it, switched to the main (master) and I can’t create a new branch from it, such an error crashes:
What is the problem?
Answer the question
In order to leave comments, you need to log in
Because initially (and even now) links (i.e. branches, tags, etc.) are stored as files in the file system (if you do not consider compression). Look, for example.
ls .git/refs/heads
Accordingly, if you already have a frontEnd/bodyStart branch, then there is a .git/refs/heads/frontEnd folder and obviously you cannot create a file with the same name.
PS Specifically, you may not have anything in the .git/refs/heads folder , because git has a storage optimization system. But for compatibility, the restriction on creating such branches still remains for compatibility.
$ ls .git/refs/heads/
master
$ git branch test/head
$ tree .git/refs/heads/
.git/refs/heads/
├── master
└── test
└── head
$ git branch test
fatal: cannot lock ref 'refs/heads/test': 'refs/heads/test/head' exists; cannot create 'refs/heads/test'
$ git branch -d test/head
Deleted branch test/head (was 58084de).
$ git branch test
$ tree .git/refs/heads/
.git/refs/heads/
├── master
└── test
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question