Change the remote URL to your repository

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