I know for a fact that a remote repo has a branch, let's call it tricky-branch
. I can see it on gitlab. But I can't seem to find a way to pull it, or even see it, locally.
I've tried:
git fetch --all
git pull --all
git branch --all
$ git checkout origin/tricky-branch
error: pathspec 'origin/tricky-branch' did not match any file(s) known to git
I know I am pointing at the right repo and the connectivity is all right, because I can push to that repo. Just not pull.
CodePudding user response:
Based on the comments, I believe you had made a single branch clone. Your new clone, where things worked, was an ordinary clone. See How do I "undo" a --single-branch clone? (though these days git remote set-branches origin "*"
is a "better" method for updating things, vs the accepted answer there).
(To find out, run:
git config --get-all remote.origin.fetch
and see what gets printed.)
Meanwhile, let's address these as well:
git fetch --all
This is sometimes useful. It probably wasn't in your case.
git pull --all
This is almost never useful.
git branch --all
This is quite useful and showing the output from this would potentially have helped here. The interesting question is, I think, "why is --all
so inconsistent", or something along these lines. The answer to that is basically that Git is a collection of ad-hoc tools: each one does its own thing, and some of them have useful --all
options and some just don't.
What --all
means to git fetch
is all remotes. In other words, if you have two or three remotes, such as origin
upstream
fred
, a git fetch --all
means that Git should run:
git fetch origin
git fetch upstream
git fetch fred
(in some order, or perhaps even in parallel).
If you have one remote named origin
, git fetch --all
means git fetch origin
, which is what git fetch origin
and git fetch
also mean. So --all
does absolutely nothing! Most setups have only one remote. (I say this without doing any statistical analysis first, but I'm pretty confident.