I just tried to checkout my master branch and ran into:
error: Untracked working tree file \'app.xcodeproj/project.xcworkspace/xcuserdata/u.xcuserdatad/UserI
For the issue in the question title, you can generally solve it this way:
git rm --cached *
fatal: pathspec 'blah' did not match any files
git ls-files
That will list the files git does have in its index, and you can then remove them explicitly one by one. If for example it lists img/blah.jpg
:
git rm --cached img/blah.jpg
This will solve the pathspec error in the more general case, whether it's a branching issue as it was in the other answer here, or a new .gitignore entry, or a result of using 2 repos in the same dir, etc.