Where's the Branch?

Date: 25 March 2018

Category: Git

Tag: General

You know that a branch exists remotely (on GitHub/TFS Git, etc.) but it isn’t appearing locally in your IDE, and running:

git checkout <branch>

doesn’t return any results. Where has the branch gone?

Hiding in plain sight

First, run the following command to ensure that the branch in question has been pushed to the remote repo:

git ls-remote origin

As per the Git documentation, this command displays references available in a remote repository along with the associated commit IDs.

Assuming the branch of interest is present in the list returned, all that is needed is a simple git fetch to download the references to the new branch. The names of refs that are fetched, together with the object names they point at, are written to .git/FETCH_HEAD.