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?
git clone --single-branch
originally? – Hugsingle_branch
option. – Longleygit fetch
does not create-or-update the appropriate remote-tracking names. What goesgit config --get-all remote.origin.fetch
produce? – Hug+refs/heads/dev:refs/remotes/origin/dev
. I think I need*
, so how can I revert configuration to * ? – Longley--single-branch
. If you didn't usegit clone --depth
orgit clone --single-branch
, you must have set it some other way. Set this back to normal, andgit fetch
will make `git checkout work again. See https://mcmap.net/q/12540/-how-do-i-quot-undo-quot-a-single-branch-clone/1256452 – Hugsingle_branch
command in the command line. You are invited to write it as an answer and I'll mark it as the best one that could help. – Longley