1

Is there a way to check whether a remote's fetch config will allow a given branch to be fetched and checked-out?

By default, any branch is in scope for fetch and checkout but if you're using "--single-branch" with your clone or you've already made surgical changes to your default fetch refspecs ("git remote set-branches"), then you might be able to force your fetch to bring down the right branch via arguments but a "git checkout" may unconditionally deny the existence of a branch.

It seems like there would at least be a plumbing feature that can filter one or more items against that config.

More context: Why can't Git resolve remote branches when --single-branch is used?

larsks
  • 277,717
  • 41
  • 399
  • 399
Dustin Oprea
  • 9,673
  • 13
  • 65
  • 105

1 Answers1

0

You can at least check the output of git config --get-all remote.origin.fetch mentioned in your linked question.

  • if you see the name of your branch, it will be fetched (and can be checked out)
  • if you see '*', chances are it could be fetched (but you would need to git fetch to be sure)
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yeah, but I'm asking about an existing pattern using the existing Git offering that might provide a one-command solution that avoids me/us having to 1) verify that the refspecs are fully-qualified and 2) having to parse the expressions direct from the config. – Dustin Oprea Mar 27 '19 at 06:54