Git Branch Exists on Remote But Won't Show Locally
📰 Dev.to · Ryan Carter
Learn to diagnose and fix git branches that exist on remote but won't show locally, using fetch refspecs and git config
Action Steps
- Check if the branch exists on remote using git ls-remote
- Verify the fetch refspec using git config --get remote.origin.fetch
- Update the fetch refspec to include all branches using git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
- Run git fetch origin --prune to update local branches
- Use git branch -r to verify the branch is now listed locally
Who Needs to Know This
Developers and DevOps engineers can benefit from this knowledge to resolve common git issues and improve their workflow
Key Insight
💡 A scoped fetch refspec can prevent git from showing all remote branches locally, but updating the config can resolve the issue
Share This
💡 Fix git branches that exist on remote but won't show locally! Update fetch refspec and run git fetch origin --prune
DeepCamp AI