Remote branch is not showing up in git branch -r
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
If a remote branch does not appear in git branch -r, the problem is usually not with the command itself. Most often, your local repository has not fetched the branch yet, the remote configuration is filtering which refs are fetched, or the branch does not actually exist on the remote you think it does.
Start with a Fetch
git branch -r shows remote-tracking refs stored locally, not a live network listing from the server. So the first fix is usually:
Then check again:
That fetch step matters because remote-tracking refs are updated only when you ask Git to refresh them.
If the branch was recently created on the server, fetching often solves it immediately.
Confirm the Branch Exists on the Remote
If fetch does not help, verify the remote actually has that branch. git ls-remote queries the remote directly:
To search for one branch specifically:
If nothing is returned, the branch either was not pushed, was deleted, or is on a different remote.
Check Which Remote You Are Using
Many repositories have more than one remote, such as origin and upstream. Confirm the configured remotes:
It is easy to fetch origin while the branch actually lives on upstream, or vice versa.
If needed:
Inspect the Fetch Refspec
Sometimes the remote is configured to fetch only selected branches. In that case, the missing branch may exist remotely but still never appear locally.
Check the fetch configuration:
A normal broad refspec often looks like this:
If your refspec is narrow, update it or fetch the specific branch explicitly:
That forces the remote-tracking branch into the local repository.
Clean Up Stale References Carefully
Stale refs can make remote branch state confusing. If branches were deleted or renamed, prune old remote-tracking refs:
This does not download missing branches, but it removes outdated ones so your view of the remote becomes more accurate.
Permissions and Server Visibility
In some hosted setups, branch visibility can depend on authentication or repository permissions. If another user can see the branch but you cannot, confirm that you are authenticated to the correct repository and have access to that branch.
This is less common than fetch problems, but it does happen in enterprise Git hosting environments.
Common Pitfalls
The most common mistake is assuming git branch -r talks to the server live. It only shows what your local repository already fetched.
Another issue is looking at the wrong remote. A branch on upstream will not appear under origin/* unless you fetched from upstream.
People also forget about custom fetch refspecs. If the remote configuration is selective, some branches will never appear unless fetched explicitly.
Finally, do not confuse a local branch with a remote-tracking branch. A branch can exist locally without any corresponding origin/name ref, and vice versa.
Summary
- Run
git fetchfirst becausegit branch -rshows local remote-tracking refs. - Use
git ls-remote --headsto verify the branch actually exists on the server. - Confirm you are fetching from the correct remote.
- Check the remote fetch refspec if some branches never appear.
- Prune stale refs so your local picture of the remote stays accurate.
Related reading
- Remote Git branches not visible
- Remote origin already exists on 'git push' to a new repository
- Remove a file from a Git repository without deleting it from the local filesystem
- Remove a folder from git tracking
- Remote debugging a Java application
- Remotely debugging my node app that is hosted on AWS
- Remove a git commit which has not been pushed
- Remove a git commit which has not been pushed
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.