I'm trying to checkout a branch that I've just fetched from my upstream remote repo but it doesn't seem to work.
$ git fetch upstream
Fetching upstream
From github.com:group/repo
* [new branch] feature-branch -> upstream/feature-branch
$ git checkout feature-branch
error: pathspec 'feature-branch' did not match any file(s) known to git.
Am I doing something wrong?
The branch is likely present in more than one remote. (You can confirm this with git branch --list --remotes '*/feature-branch'.) git checkout only creates branches like that if they’re unambiguous. From git-checkout(1):
If
<branch>is not found but there does exist a tracking branch in exactly one remote (call it<remote>) with a matching name, treat as equivalent to$ git checkout -b <branch> --track <remote>/<branch>
So you’ll need to do that instead:
git checkout -b feature-branch --track upstream/feature-branch
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