Last Try Before solving Problem: shows the line which dont recognition the Mother Branch
Here is The Code:
First i initialized a repo:
$ git init
then renamed Master to Mother:
$ git branch -m "Mother"
created a readme.md:
$ touch "readme.md"
The First error when i tried to create a new branch then, I got caught in it was(exactly is shown in the first image):
$ git branch Product
fatal: not a valid object name: 'Mother'
after creating several branches by alt:
$ git checkout -b Product
Switched to a new branch 'Product'
and commiting the readme.md file..
i tried to switch to The previously created branches but the main question is here:
$ git checkout Product
error: pathspec 'Product' did not match any file(s) known to git
this even happened for my Root:
$ git checkout Mother
error: pathspec 'Mother' did not match any file(s) known to git
so i recreated those branches again:
$ git checkout -b Product
Switched to branch 'Product'
The Problem Solved but whats the reason behind it
may you tell me why?
new edit: 'im intern'
CodePudding user response:
Branches in Git are pointers to existing commits. When you init
, your repository has 0 commits, thus you cannot create any branches. Once you have a commit, you can create new branches.