Change or transfer repository ownership

If you have administrative rights on a repository, you can change or transfer the ownership of a repository to another team or to a individual account. The account holder you are transferring to must accept the transferred repository to complete the transfer. You can revoke a pending transfer before it is accepted. Transferring a repository transfers the commit history, issue tracker, and wiki associated with that repository.

It is important to understand that changing a repository's ownership, changes the URL you (and others) use to access the remote repository from your local system. For example, if a repository is owned by the thecodemeister and the repository's name is coolcode, the URLs used to access the repository are the following:

https://thecodemeister@bitbucket.org/thecodemeister/coolcode

After transferring coolcode from the thecodemeister to the newowneract account, the URLs look like this:

https://newowneract@bitbucket.org/newowneract/coolcode 

Changing the ownership of a repository on Bitbucket changes information only on the Bitbucket Cloud server. Repository configuration files on local systems are not changed. This means, you must change local references to that repository manually or re-clone the repository after it changes.

Page contents:

How to transfer a repository

Make sure you know which user you want to transfer the repository to before you begin. Then, do the following:

  1. Log into Bitbucket using the account that owns the repository.
    This is the user the repository is transferring from.
  2. Go to the repository you want to transfer.
  3. Go to the repository's settings, in the left side menu.
  4. Scroll down and you'll see Transfer or delete repository. Click on Transfer repository, the Transfer repository window will pop up.
  5. Enter the Username of the individual or team account you want to transfer to.

  6. Press Transfer.
    The Bitbucket server sends the user or team account an email notification containing a transfer request. The Transfer repository page changes to indicate that you have transferred the repository.

    Additionally, the system displays a pending transfer banner at the top of each repository tab. This warns others who have access to your repository that a transfer is pending. You are able to revoke the transfer request at any time before the new user accepts it. If you revoke a transfer before a user accepts it, Bitbucket sends the user a notification that the transfer was rescinded.

What happens when a repository transfers?

When you transfer a repository to an account, Bitbucket sends an email notification to the account holder. The message contains a link to a page that allows the user to accept or reject the transfer. The account holder you transfer to may have administrative rights on multiple user or team accounts. If the account holder has administrative access on more than one account, then he or she can transfer the repo into any of these accounts.

When your transfer is accepted, Bitbucket automatically updates all the repository URLs on the Bitbucket site. The repository is accessible from it's new location – and the new owner's account name in the repository's URL. For example, suppose the location of the repo before transfer to newowneract is this:

https://thecodemeister@bitbucket.org/thecodemeister/coolcode 

After transferring coolcode from the thecodemeister to the newowneract account, the URLs look like this:

https://newowneract@bitbucket.org/newowneract/coolcode 

All the access rights are removed from the transferred repository and the previous administrator receives a notification of this change.

The new repository owner must configure the transferred repository's access permissions after receiving the transfer.

A transferred repository does not inherit the destination account's permission configuration.

Accepting a transferred repository

If you receive a transfer request, you accept it by doing the following:

  1. Open the transfer request message.
  2. Click on the link provided. If you're not logged in to Bitbucket, you'll have to log in first.
  3. Press Accept transfer.
    Once you accept the request, the repository shows up on your list of repositories. Bitbucket updates all URLs on the server and the repository is accessible from it's new location. The original owner of the repository automatically has delegated administrative access to the repository at its new owner/location. To change or remove this access, go to the repository's Settings > User and group access page. If you choose to reject a transfer, Bitbucket sends a message to the sender of the request.

Updating local configuration files with the new repository location

After changing the ownership of a repository, you must update any configuration files that contain the old URLs.

If you don't do this, you will get an error attempting to push your repository to the Bitbucket server. For Git, this error looks similar to the following:

git push
Password: 
fatal: https://newowneract@bitbucket.org/newowneract/coolcode.git/info/refs not found: did you run git update-server-info on the server?

The exact error message you get depends on which protocol you are using to access the repository. To fix this problem, you can edit the repository URL in your repository's configuration file.

  Show me how the different URLs look

The following table illustrates a repository location under the various protocols before and after a transfer. For example, if your username is thecodemeister and the repository's name is coolcode, the URLs used to access the repository are the following:

  SSH format URL HTTPs format URL
Git

git@bitbucket.org:thecodemeister/coolcode.git

or

ssh://git@bitbucket.org/thecodemesiter/coolcode.git

https://thecodemeister@bitbucket.org/thecodemeister/coolcode 

Mercurial ssh://hg@bitbucket.org/thecodemesiter/coolcode/

https://thecodemesiter@bitbucket.org/thecodemesiter/coolcode

If you transfer the repository to a new team called, newowneract, the new URLs will look like this:

  SSH format URL HTTPs format URL
Git

git@bitbucket.org:newowneract/coolcode.git

or

ssh://git@bitbucket.org/newowneract/coolcode.git

https://newowneract@bitbucket.org/newowneract/coolcode 

Mercurial ssh://hg@bitbucket.org/newowneract/coolcode/

https://newowneract@bitbucket.org/newowneract/coolcode

Get the current remote URL information for your Git repository

  1. Navigate to your repository's directory in a terminal window using the command cd path/to/your/repository.
  2. Run the following command from your terminal window:
git remote -v

This should give you something similar to one of the following results:

For SSH
origin    git@bitbucket.org:teamsinspace/documentation-tests.git (fetch)
origin    git@bitbucket.org:teamsinspace/documentation-tests.git (push)
For HTTPS
origin    https://dans9190@bitbucket.org/teamsinspace/documentation-tests.git (fetch)
origin    https://dans9190@bitbucket.org/teamsinspace/documentation-tests.git (push)
If you don't want to edit the configuration file, you can also simply clone the repository from the new location. Be aware that you will lose any changes you made but had not pushed up to the remote (Bitbucket) before the repository was transferred.

Modify your Git remote URLs

You will need to know if you're using SSH or HTTPS before changing your URLs. If you are unsure which method you're using you can find your remote URLs.

  1. Navigate to your repository's directory in a terminal window using the command cd path/to/your/repository.
  2. Run the following command (which modifies the fetch URL) from your terminal window:

    For SSH
    git remote set-url origin git@bitbucket.org:{new team or account name}/{repository name}.git
    For HTTPS
    git remote set-url origin https://{username}@bitbucket.org/{new team or account name}/{repository name}.git
  3. Run the following command (which modifies the push URL) from your terminal window:

    For SSH
    git remote set-url --push origin git@bitbucket.org:{new team or account name}/{repository name}.git
    For HTTPS
    git remote set-url --push origin https://{username}@bitbucket.org/{new team or account name}/{repository name}.git

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport