When Git Cannot See a Remote Branch
When Git Cannot See a Remote Branch: origin/dev Not Found While working on a Git repository, I encountered a situation where Git could not see a remote branch even though it clearly existed on the remote server. The error message was: fatal: invalid reference: origin/dev At first glance this looks strange. If the branch exists remotely, Git should be able to track it locally. The issue turned out to be related to how Git fetches remote branches. Verifying That the Remote Branch Exists The first step was to check whether the branch actually existed on the remote repository: git ls-remote --heads origin Example output: 670b975870485f20dc6d793f922848b2382df294 refs/heads/dev be714f052262f6b7bc080492f24dd8e3a9ab410d refs/heads/main This confirms that the dev branch exists on the remote repository. However, locally the branch was not visible: git branch -r The output was empty. Trying to switch to the branch failed: git switch -c dev origin/dev ...