Skip to content

Instantly share code, notes, and snippets.

@ComFreek
Last active December 14, 2020 12:08
Show Gist options
  • Save ComFreek/a3be9997cfe2b684882b3baa8bb8852f to your computer and use it in GitHub Desktop.
Save ComFreek/a3be9997cfe2b684882b3baa8bb8852f to your computer and use it in GitHub Desktop.
Fix: Git cannot checkout remote branches

Problem: Despite git fetch --all, git branch --all just shows your local branches.

Cause: Did you clone your repository initially with git clone -b <branch name> <remote>? You can very this by running:

$> git config remote.origin.fetch

+refs/heads/<branch name>:refs/remotes/origin/<branch name>

If you get an output like the one above, you did initially clone with -b most likely.

Solution: git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment