Reputation: 85
After I try to create new branch by either commands new branch is either not created or master is gone. If I use command git branch newBranch
branch is not created.
If I use command git checkout -b newBranch
new branch is created but master branch is gone.
`
Upvotes: 0
Views: 1186
Reputation: 1323793
First, use the new git switch
command, not the old confusing git checkout
one.
git switch -c newBranch
Second, make sure you have a master
branch to begin with, meaning git log --decorate --oneline --graph --all --branches
shows at least one commit in the master
branch.
Not "origin/master
", but master
.
You can list all branches with git branch -avv
.
If you had zero commit in a newly initialized repository, then there would be no branch at all, as seen here.
The OP mat1 confirms in the comments:
I have made first push to remote repo, now it works.
Because I didn't have made initial commit and push , that is why I could not create branch.
Upvotes: 1