I'm just a beginner and I practiced merging.
- I deleted folder A that I practiced.
- And I created a new folder B. I did the following work at B.
$ git init
$ (master) touch defalt.txt
$ (master) git switch -c foo
$ (foo) git branch
>>> *foo
The master branch has disappeared.
Maybe something is wrong when working at A.My
.git/config
repositoryformatversion = 0
efilemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
How can I check the problem?
Did I change the git setting?
I don't know what's wrong. Please help me
CodePudding user response:
Your prompt is (in)directly using the contents of .git/HEAD
as the name of the current branch, but the branch it references doesn't actually exist until you create a commit. (You can see this by looking at the contents of .git/HEAD
and the contents of .git/refs/heads
.)
master
didn't disappear; it never existed in the first place.
.git/HEAD
might refer to a branch head (which may or may not exist/refer to a commit yet) or it might refer to some other commit that is not a branch head (a so-called detached head). (There might also be some other corner case I've missed.)
CodePudding user response:
Your master
is what is known as an unborn branch — a branch that exists potentially in a new repository, just so your first commit has a branch to go onto, but does not exist in reality until and unless you do put a commit onto it.
An unborn branch is never listed in git branch
; the git switch
in your question is a red herring, as the branch wasn't listed before the switch either! It won't be listed unless you switch back to it and commit onto it.