If a remote Bitbucket branch is missing, first confirm it’s actually gone from the remote by running git fetch --all --prune and checking git ls-remote origin. If it still exists, your local repo just hasn’t refreshed and git switch or git checkout will fix it. If it’s truly deleted, the fastest recovery is usually the Bitbucket web UI’s branch or commit history, or a teammate’s local copy that still has the branch. Only after those fail should you rely on server-side reflog or Bitbucket Support, because ordinary users can’t run git reflog on Bitbucket’s servers.

That answer assumes a few things worth spelling out. “Retrieve” can mean three different jobs: getting a branch that exists on the remote into your local working copy, finding a branch you deleted remotely by accident, or recovering a branch whose remote repository itself was moved, renamed, or made private. Each has a different toolset, and mixing them up wastes time. The steps below separate those cases, put prerequisites first, and give you a concrete check at each stage so you know whether to keep going or stop.

First, separate “not fetched” from “actually deleted”

Most “missing branch” reports are a local problem, not a Bitbucket problem. Your clone only knows about branches it has fetched, and Git prunes tracking refs conservatively. A branch created by someone else yesterday may simply not exist in your local .git/refs/remotes/origin/ yet.

The check is one command against the remote itself, which bypasses local state:

git ls-remote --heads origin lists every branch currently on origin. git fetch --all --prune updates your remote-tracking branches and removes refs whose upstream branches are gone.

Run the fetch first, then the listing. If your branch appears in the ls-remote output but not in git branch -r, your local refs were stale. If it appears in neither, and you have permission to see the repository, treat it as deleted or renamed on the server side.

Success condition: the branch name shows up in git ls-remote --heads origin. At that point you can retrieve it locally with git switch (Git 2.23 and later creates a local tracking branch automatically) or the older git checkout -b origin/. If switch complains the branch already exists locally but is out of date, git fetch origin followed by git reset --hard origin/ aligns it, but only after you’ve confirmed you have nothing uncommitted you care about.

One access wrinkle: ls-remote failing with an authentication or “repository not found” error often means permissions, not deletion. Bitbucket returns the same ambiguity for private repos you can’t see. Confirm you can open the repository in a browser while signed in before concluding the branch is gone.

Retrieve an existing remote branch into your local clone

When the branch is confirmed present remotely but you need it locally, the procedure is short and reversible.

Prerequisites: a clone of the repository, network access to Bitbucket, and credentials or an SSH key that can read the repo (an app password or access token for HTTPS, or a key registered to your Bitbucket account). Know whether you’re on Bitbucket Cloud (bitbucket.org) or Bitbucket Data Center, because the web UI differs even though Git commands are identical.

1: git fetch origin refreshes remote-tracking refs without touching your working tree. 2: git branch -r or git branch -r --list 'origin/*' confirms the remote-tracking ref exists. 3: git switch creates a local branch tracking origin/ and checks it out. Older Git versions: git checkout --track origin/. 4: git status and git log --oneline -5 verify you’re on the right commit.

Expected result: your prompt reflects the branch, and the tip commit matches the remote’s. Check success by comparing git rev-parse HEAD with git rev-parse origin/, which should print identical hashes.

Two common snags. If switch creates the branch from the wrong base, you probably have a local branch with the same name already; delete or rename it first, since Git won’t silently overwrite. If fetch succeeds but switch says “invalid reference,” the branch may live under a different remote name than origin, which happens in forks and multi-remote setups. Run git remote -v to see the actual names, then use that remote in the tracking command.

Recovering a branch that was deleted on the remote

This is the case the query is really about, and it needs a different approach because there is no live ref to fetch. Git doesn’t keep a permanent list of deleted branches on the server, and Bitbucket doesn’t expose git reflog for the hosted repository to normal users. Recovery therefore depends on finding a surviving reference to the deleted tip commit.

Order the attempts from least to most disruptive:

Bitbucket web history. Open the repository, go to the branches or commits view, and look for the branch in the activity or pull request history. Bitbucket Cloud shows recent branch deletions in the repository’s activity feed, and a merged or declined pull request that used the branch retains a link to its commits. From there you can open the commit, view its hash, and recreate the branch locally with git switch -c and push it back with git push -u origin . The same hash-first approach works in Data Center through the commit or pull request pages. This is the most reliable path for ordinary users, and it requires no server privileges.

A teammate’s clone. Anyone who fetched the branch before deletion still has origin/ in their local repo, and often a local branch too. Ask them to run git push origin from the clone that still has it. This is a legitimate and common recovery route; it doesn’t require admin rights and reconstitutes the exact tip. If their copy is behind the last state, you’ll recover an older tip, which is usually better than nothing and worth disclosing to the team.

Your own reflog, only if you had the branch locally. git reflog on your machine lists local ref movements, not server events. If you previously checked out or fetched the branch, your reflog or git fsck --lost-found may still surface the dangling commit for a while. This recovers your copy, not necessarily the remote’s final state, and the grace period before garbage collection varies, so try it soon and treat success as a bonus rather than a plan.

Repository administrators. Bitbucket Data Center administrators can inspect the server-side repository, and Bitbucket Support can sometimes help with Cloud repositories depending on plan and timing, but this is not a routine self-service feature. Don’t promise a colleague you’ll “get it from the server” before confirming what your organization’s Bitbucket plan and admin access actually allow.

A stop condition: if none of the web history, a teammate clone, or your own reflog yields the commit, further recovery on a hosted Bitbucket repo isn’t something an ordinary user can perform. Treat it as lost beyond the tip you can reconstruct from other branches and pull request diffs, and escalate to your Bitbucket administrator rather than attempting server-side tricks.

When the branch moved, was renamed, or vanished with the repository

Not every missing branch is deleted. Three other causes produce the same symptom and need different fixes.

Renamed branch. Git has no rename tracking for branches. The old name disappears and a new one appears, usually with the same tip commit. Compare the hash: git ls-remote --heads origin shows hashes alongside names, so if a branch you don’t recognize points at the commit you expected, that’s your renamed branch. Switch to the new name and delete the old local tracking ref.

Repository renamed or transferred. Bitbucket redirects many old URLs, but Git remotes store literal URLs. If the workspace or project moved, git fetch may fail rather than find the branch. Update with git remote set-url origin or git remote set-url origin after checking the repository page for its current clone URL, then fetch again.

Fork versus upstream confusion. In a fork-based workflow, a branch pushed to someone’s fork isn’t on the upstream repository’s origin. git remote -v and git ls-remote clarify where the branch actually lives. Retrieve it by adding that fork as a remote (git remote add teammate ), fetching, and switching to the tracking branch.

A version-specific note: behavior around git switch versus git checkout, and default branch naming (main versus master), varies by Git version and repository configuration. Commands above work on Git 2.23 and later; older installations should substitute git checkout equivalents. None of these Git operations differ between Bitbucket Cloud and Data Center, but the web UI paths do, so follow the labels your instance actually shows rather than a screenshot from a different product.

Prerequisites, permissions, and access tokens

Retrieval fails more often on access than on Git mechanics. Before any command, confirm:

You can open the repository in a browser while signed in. If not, ask the repository admin for read access; no Git command will bypass that. HTTPS clones need an app password or access token with repository read scope, not your Bitbucket account password, for Cloud. Data Center typically uses personal access tokens or HTTP access tokens depending on version and admin configuration. SSH clones need your public key registered and the correct host in ~/.ssh/config. For a fork contributed to by others, confirm which remote actually holds the branch.

Check success early with git ls-remote origin HEAD, which returns the default branch’s hash if authentication and connectivity are fine. If that fails, fix credentials before troubleshooting branch-specific issues; a failing ls-remote and a missing branch produce identical error text in some cases.

A worked recovery example

Suppose a teammate deleted feature/checkout-v2 on Friday, and on Monday you need its last commit. You run git fetch --all --prune; the branch is gone locally and absent from git ls-remote --heads origin. You open the repository’s pull request list, find the merged PR titled “Checkout v2,” and the PR page shows the merge commit and the branch’s commits. The branch’s tip commit is a1b2c3d. You run git fetch origin to be current, then git switch -c feature/checkout-v2 a1b2c3d, verify with git log --oneline -3 that the commits match the PR, and push with git push -u origin feature/checkout-v2. The branch is back with its historical commits intact.

If the PR had been deleted as well, the next move is a colleague who had the branch checked out. If nobody did, the commit may still exist as part of another branch’s history if it was merged, in which case git log --all --oneline --grep="checkout v2" or browsing the commit graph can locate it. Recreating the branch at that commit gives you the code, though the branch’s unmerged side commits, if any, are what actually get lost.

What “retrieval” can’t do, and when to stop

Set expectations honestly. Hosted Bitbucket doesn’t provide a self-service server-side reflog, so “undelete” isn’t a button. The realistic recovery window depends on whether a pull request, activity entry, teammate clone, or your own local reflog still references the tip; there’s no fixed retention period you can rely on across plans and configurations. If the branch held unmerged work and no surviving reference exists anywhere, the content is gone, and the responsible move is to reconstruct from memory and diffs rather than promise a restore that won’t happen. Escalate to your Bitbucket administrator when web history and teammate copies are exhausted, and stop attempting workarounds that involve altering server repositories you don’t administer.

The practical summary: verify with git ls-remote before assuming deletion, retrieve existing branches with git fetch plus git switch, recover deleted ones through the web UI’s commit history or a teammate’s clone, and check permissions first when commands fail unexpectedly. That sequence covers nearly every real “missing remote branch” situation without guesswork.