How to copy a repository between two different Bitbucket environments.
I have two different Bitbucket environments. I want the repositories to progress in the same way between them.
There are a few ways to do this, but the "cleanest" way to ensure you don't lose your commit history, branches, or tags is to do a mirror push via your local machine. You don't need any special tools—just a standard terminal.
1. Create the target repo:
First, go to your new Bitbucket workspace/account and create a brand-new, empty repository. Don't initialize it with a README or .gitignore yet.
2. Clone the original as a "bare" repo:
This pulls down all the metadata and branches without the working files.
git clone --bare https://bitbucket.org/OLD_WORKSPACE/old-repo.git
3. Move into that folder:
cd old-repo.git
4. Mirror push to the new home:
git push --mirror https://bitbucket.org/NEW_WORKSPACE/new-repo.git
5. Clean up:
You can now delete the old-repo.git folder on your local machine and clone the new repo normally.
A few things to keep in mind:
Permissions: Make sure your SSH key or App Password has "Write" access to the new destination.
Pull Requests and Pipelines: This moves code and history, but it won't move your PRs or build history.
LFS: If you use Git LFS, you’ll need to run "git lfs fetch --all" and "git lfs push --all" to move those assets.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.