Reinstating deleted Bitbucket repositories from a local copy

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

This article describes a scenario where a repository which was hosted in Bitbucket Cloud was deleted, and needs to be reinstated for any reason.

Solution

Requirements

There are a couple of requirements that you need to meet before you proceed with the steps to recover the repository:

  1. To reinstate the repository, please make sure that you have a local copy of the repository that has most or all branches from the deleted repositories.

    You can check if it was a local copy of the previously deleted repository by running the following command:

    1 git remote -v

    Make sure that the URL that shows up matches the URL of the previously deleted repository.

    In addition to that, you can check if your local copy of the repository has multiple branches by running the following command on it:

    1 git branch -a
  2. You need to have the ability to create new repositories under the affected workspace (admin or write access to the target workspace);

  3. You need to have either an SSH key or App password added to your personal settings, so you can authenticate against the target workspace.

Steps to recover the repository

  1. Create a new repository on the desired workspace;

  2. Once the repository is created, on the source tab of the new repository, click on the "Clone" button. You should see a pop up similar to the one below:

    (Auto-migrated image: description temporarily unavailable)

    1. If you have an SSH key added to your personal settings, please select SSH on the dropdown in the top right corner of the pop-up;

    2. If you have an App password added to your personal settings, please select HTTPS on the dropdown in the top right of the pop-up.

  3. From the pop up above, copy everything after the "git clone" section. You should have either git@bitbucket.org/:<workspaceID>/<repoSlug>.git or https://bitbucket.org/<workspaceID>/<repoSlug>.git on your clipboard.

  4. On the local copy of the repository, run the following command, using what was copied on step 2 as <remoteURL> :

    1 git remote set-url origin <remoteURL>
  5. Run the following command to push to Bitbucket:

    1 git push --force --all
  6. Navigate to the repository on Bitbucket. Make sure to validate if the branches and commits match the local copy of the repository:

    1. To check the commits, run the following command on the local copy of the repository, and compare it to the commits section of the repository on Bitbucket Cloud.

      1 git log
    2. To check the branches, run the following command on the local copy of the repository, and compare it to the branches section of the repository in Bitbucket Cloud.

      1 git branch -a

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.