4

We ran into a problem with our development branch. Long story short, I've deleted the branch and recreated it from master. However, every time we create a new clone of the repository and checkout development we get the following:

$ git checkout development
error: pathspec 'development' did not match any file(s) known to git.

I'm able to get around the problem using Gregory McIntyre's answer from:

Git: cannot checkout branch - error: pathspec '...' did not match any file(s) known to git

git checkout -t -b development origin/development

I can then use the branch as normal.

However, the next time we clone the repository we'll have the same problem and have to use the same fix.

It's only the development branch that's having this problem, other branches work as expected after a fresh clone:

$ git checkout staging
Branch staging set up to track remote branch staging from origin.
Switched to a new branch 'staging'

Is it possible to fix the development branch so that the workaround isn't required?

Community
  • 1
  • 1
Ken
  • 86
  • 1
  • 8
  • 1
    Automatic creation of a local branch tracking a particular remote branch with a sufficiently similar name happens only if there's *exactly one* match, so the obvious question is, what does `git branch -r` or `git branch -a` produce? – torek May 29 '15 at 18:05
  • `git branch -r` shows one reference with development `origin/development`. `git branch -a` shows a single reference to development as well `remotes/origin/development`. There are a number of other branches (master, staging, branches related to ticket #'s), but nothing else with development in the name. – Ken May 29 '15 at 18:24
  • Interesting - I'd try cut-and-paste, or any other similar trick, to see if there's some weird character(s) in the branch name. But at this point it *looks* like it should just work... – torek May 29 '15 at 21:57
  • I've tried copying and pasting the name, deleting and re-creating the branch, using a different user/computer, and still no dice. Anything else you can think of to look at? – Ken Jun 01 '15 at 20:33
  • Nothing else comes to mind. That's definitely weird. – torek Jun 01 '15 at 20:45
  • Here is the link to my answer for similar question: (https://stackoverflow.com/questions/5989592/git-cannot-checkout-branch-error-pathspec-did-not-match-any-files-kn/51770903#51770903) – Shradhey Tripathi Oct 10 '18 at 17:04

1 Answers1

0

You will first need to retrieve the available branches of a repository. For example:

git fetch --all --prune

Once Fetching origin is done & your prompt returns, go ahead with your checkout as usual.

Grant
  • 5,709
  • 2
  • 38
  • 50