Pointing Bitbucket at an existing repository
Asked by Bill Wohler:

We don't need a Git repository as we already have one. We just purchased Bitbucket (server) for its code review features. I was a little surprised to find that it doesn't appear to be possible to point it at an existing repository. It seems that we'd have to clone our existing repositories into Bitbucket and then abandon those repositories.

Is it true that Bitbucket only works with internal repositories? If so, why is that?


Answers:
author: Pramodh M
body: Hi [@Bill Wohler](/t5/user/viewprofilepage/user-id/562339)

You have to understand how Git works here.

For any changes to be appeared in the Bitbucket server first create a repository, and wherever your repository is you can push the changes to your server by adding the remote link to your server.

I'm not sure what you mean by internal repositories, please let me know more on that.

Thanks,  
Pramodh

comments: author: Bill Wohler
body: Thanks, Pramodh. Let's see if an example will help. Our external Git repository is at, say, git.domain.com and our Bitbucket server is at bitbucket.domain.com. I was referring to any repositories at bitbucket.domain.com as internal. I want the Bitbucket server to use the Git repository at git.domain.com. In other words, our developers want to keep developing on git.domain.com and view their code reviews on bitbucket.domain.com.


author: Pramodh M
body: Say what is this git.domain.com is? which is this external Git repository?

Could you please help me understand here?

And is bitbucket.domain.com Bitbucket Server


author: Bill Wohler
body: We've cloned from git.domain.com:

\[wohler@host project (master=)\]$ git remote -v  
origin ssh://git.domain.com/GIT/project.git (fetch)  
origin ssh://git.domain.com/GIT/project.git (push)

It would be preferable if this doesn't change for our developers.

Yes, bitbucket.domain.com is the Bitbucket server.


author: Pramodh M
body: The requirement is very strange, I guess what you are trying to say is mirroring.

Here's an idea you can try.

Let Bitbucket handle all the git operations (fetch and push) and pull requests.

What you can do is, write a custom script to push the code from the Bitbucket server to External Git Server, or the other way around works too.


author: Bill Wohler
body: I think what you are saying is that you can't point Bitbucket to an external repository.

Our team would also like to know why that is so.


author: Pramodh M
body: Yes, that is correct. Because such feature is not available yet!

But it can be achieved via Mirroring.


author: Christian Glockner
body: Hi Bill,

Bitbucket Server is not just a code review tool but rather a tool that allows you manage git repositories hosted on it, including code reviews as part of pull requests.

Bitbucket's model is built around the repositories being hosted locally, and that's the way it's always been.

You're probably aware, but you can import your existing repo into Bitbucket Server and then work with that repo instead. We've got details on how to do that at <https://confluence.atlassian.com/bitbucketserver/importing-code-from-an-existing-project-776640909.html>

Cheers,

Christian

Premier Support Engineer

Atlassian


author: Pramodh M
body: I have seen some customers who already have some external git server but they want the code in these famous Git hosting tools like Bitbucket, and you know what I'm going to say next ? Just making a joke there, please don't send this to spam ?

In this case, if they are strict about what they are following we have the option of mirroring.

If they are willing to change the entire system to Bitbucket, that's good too!!

Thanks,  
Pramodh


author: Bill Wohler
body: Christian, thanks for sharing the design model. That certainly makes sense.

To help you understand why I'm asking, our need to switch our Git repository to Bitbucket is causing a bit of a kerfuffle in our NASA group with its rigid security plans.

Pointing Bitbucket to an external repository in order to get all of the benefits of Bitbucket aside from hosting might not be a frequent requirement, but it is important in our case.


Tags: bitbucket-server

server