Here is my complete, step-by-step guide on how to recover a deleted branch in Azure DevOps, covering everything from the web portal to command-line saves.
How to recover deleted branch in Azure DevOps
Method 1: The Web Portal (The Easiest Method)
Log in to your Azure DevOps organization. Navigate to your Project, then hover over Repos in the sidebar and select Branches.
Step 2: Search for the Deleted Branch
By default, the “Mine” and “All” tabs only show active branches. If you scroll through the list, you won’t see your deleted branch.
- Locate the “Search all branches” box in the top right corner.
- Type the exact name of the deleted branch.
- Note: Partial matches often fail here. You need the full string, e.g.,
feature/login-updaterather than justlogin.
- Note: Partial matches often fail here. You need the full string, e.g.,
- Once you hit enter, you will likely see “No branches found.” Look closely for a link that appears below the search bar saying: “Search for exact match in deleted branches.”
Step 3: Restore the Branch
Click that link. Azure DevOps will query the recycle bin for that specific string.
- Your branch should appear in the list with a Deleted status.
- Hover over the row to find the actions menu (the three vertical dots
...). - Select the Restore branch. Check out the screenshot below for your reference.

The system will recreate the branch pointing to the exact same Commit ID (SHA) it was at when it was deleted.
Method 2: recovering via Git Reflog
Sometimes, you might not have access to the Azure Portal, or perhaps you deleted the branch locally and propagated that deletion to the remote. In these cases, I prefer using the command line. It makes me feel more in control of the Git history.
This method relies on git reflog, which is essentially a history of everywhere your HEAD pointer has been.
Step 1: Find the Commit ID
Open your terminal or command prompt in your repository folder. Run the following command:
Bash
git reflogYou will see a list of moves. Look for the entry where you moved away from the deleted branch or the commit message associated with the tip of that branch. You are looking for the SHA-1 hash (the alphanumeric code, e.g., a1b2c3d) next to that state.
Step 2: Recreate the Branch Locally
Once you have the SHA, you can resurrect the branch from that specific point in time.
Bash
git checkout -b <branch_name> <sha_id>- Replace
<branch_name>with your original branch name. - Replace
<sha_id>with the hash you found in the reflog.
Step 3: Push to Azure DevOps
Now that the branch exists locally, you simply need to push it back to the remote server to “restore” it for everyone else.
Bash
git push origin <branch_name>