I have a serious issue with git. My client runs a repository on GitHub. I am working on the main branch and want to checkout a release branch.
The issue: my git-cli can’t check this branch out.
I ran:
git branch -a
Result:
* main
remotes/origin/feature/commander
remotes/origin/release/0.88
remotes/origin/release/0.89
remotes/origin/release/0.89
and so on
So i want to checkout the release-branch 0.89 using several attempts that I found here on StackOverflow and in git-tutorials:
git checkout release/0.89
error: pathspec ‘release/0.89’ did not match any file(s) known to git
git checkout remotes/release/0.89
error: pathspec ‘remotes/release/0.89’ did not match any file(s) known to git
I found also something like this, that I usually use to create a new remote branch:
git checkout -b release/0.89 origin/release/0.89
this gives an error:
fatal: 'origin/release/0.89' is not a commit and a branch 'release/0.89' cannot be created from it
I am using git version 2.34.1 on Ubuntu 22.
What do I wrong?
3
Answers
Yes you can. Just perform
It has to include the remote, otherwise git will try to create a local branch with that name from a remote branch that has that name if there is a single remote that has a branch with that name….. so, try this:
You will end up in
detached HEAD
state, which is to be expected.Okay, so first, it looks like you’ve wrongly created a local branch with the name
remotes/origin/release/0.89
. So your first move should be to delete it:If that works, then
git branch -a
will only list oneremotes/origin/release/0.89
.In that case, you can now do this correctly, which is to say:
That will create a local branch,
release/0.89
, based off of the remoterelease/0.89
(and Git will tell you so).