Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to import git repository without http prefix?

Baztheman June 13, 2019

Hi, 

All the import instructions I have found are related to source repository with URL, http preflix.

 

If i normally do a "git clone git:/git/software/xxx.git" with git is the hostname, how can I import this to BB and maintain the history?

 

Thanks.

 

B.

1 answer

0 votes
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 13, 2019

Hi Barry,

To import an exiting repository using SSH (that is what the git: prefix means) you need to:

  1. clone your existing repository using the --bare parameter:
    git clone --bare git:/git/software/xxx.git
  2. If you have not done so already, create a new repository on your Bitbucket Server
  3. Add your SSH key to either your profile in Bitbucket or as a access key for the repository.
  4. Once the SSH key is added and you click on clone for this new Bitbucket repository, it should show you the ssh URL for it, like ssh://git@bitbucket:7999/pr/xxx.git
  5. cd into your bare clone, and add Bitbucket as a remote
    cd my_repository
    git remote add bitbucket ssh://git@bitbucket:7999/pr/xxx.git
  6. Push everything to Bitbucket
    git push --all bitbucket
    git push --tags bitbucket
  7. Remove your bare clone of the repository.

You can also replace the origin URL instead of adding an extra one for Bitbucket. Just use the below command in step 5 instead of git remote add...

git remote set-url origin ssh://git@bitbucket:7999/pr/xxx.git
Baztheman June 13, 2019

Mikael, thank you for your quick answer. Yes thats what I am doing cause I couldnt figure out how to import with the "git:" prefix. Barry

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events