I am trying the checkout a branch from a remote repository into a local branch, and receive the above error.
For those who want to direct me to:
Why is it not a commit and a branch cannot be created from it?, then I already tried fetching, and even
git fetch --all
To be precise, I cannot checkout any branch on the Github repository, that is not the main branch that I'm tracking, let's call it dev
.
So, I can do the following:
git checkout origin/dev -b my_own_dev_env
But I cannot checkout any other branch, not even
git checkout origin/master -b master
And in this case I receive
"fatal: 'origin/master' is not a commit and a branch 'master' cannot be created from it"
Edit: When cloning to a new directory, I can perform all git operations as usual. So I would like to know what could go wrong in a local copy that prevents git commands from working properly?
First check whether you have fetched all branches or not by executing following command.
git fetch --all
Check for existence of branch name in local
git branch -a
Execute command to track remote branch and create one in local
git checkout -t origin/<Branch Name>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With