Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Initiating a repository based on a local repository

LV October 11, 2024

I have a git repository, a "local" one on my PC and a remote one hosted locally on my private network.

I would like to replace this locally-hosted remote repository by a bitbucket one. And I don't find the steps to do this. 

All the instructions I see relies on the repository to clone be available by a public url. Which is not my case.

How should I do ?

1 answer

1 accepted

2 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 14, 2024

Hi @LV and welcome to the community!

Assuming that your PC can access the server where this repository is hosted, you can do the following:

1. Create a new empty Bitbucket Cloud repository from our website. Ensure that the options for README and .gitignore in the repository creation page are both set to No, so that the repository is empty.

2. On your PC, take a mirror clone of the repo

git clone --mirror repo_url_on_your_private_server

A mirror clone will get all branches, if the repo has more than one branch.

3. Switch to the directory of your mirror clone

4. Add a new remote URL to that mirror clone that points to the empty Bitbucket repo you created in Step 1.

git remote add bitbucket git@bitbucket.org:workspace-id/repo.git

where workspace-id and repo replace with the values for your Bitbucket repo. This is an SSH URL, but you can also use an HTTPS one instead, if you haven't set up SSH:

git remote add bitbucket https://username@bitbucket.org/workspace-id/repo.git

where username, workspace-id and repo replace with the values applicable to your user and repo.

5. Afterwards, push to the Bitbucket repo with the command

git push --all bitbucket

Please feel free to reach out if you have any questions.

Kind regards,
Theodora

LV November 5, 2024

Thanks ! It worked.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events