kojiro
kojiro

Reputation: 77089

Two-step git import over ssh

Bitbucket has an importer tool for importing repositories from remote locations, but it only supports the git:// protocol. Our existing repositories are on a company controlled machine behind a firewall that I can't change, and git:// is not available. I need to move the repositories from our company machine to bitbucket, keeping all history and details from the original repository intact.

Is there some way I can accomplish this by cloning the original repository via ssh to a local machine, and then pushing that repository to a newly-bare-initted repository on bitbucket? Will I lose any history or data that way?

(I'm hoping for an answer that isn't bitbucket specific, but will work for "moving" a git repository in any case.)

Upvotes: 7

Views: 3830

Answers (3)

Erik van Zijst
Erik van Zijst

Reputation: 2331

What makes you think that we only support the git:// protocol? We support the smart http protocol and so for instance you can just import https://github.com/jquery/jquery

So if your repo is accessible from the Internet and does HTTP(S) then you should have no problem using the importer (which does a proper clone and do preserves history).

Upvotes: -1

Marcus
Marcus

Reputation: 4020

You'll want to be sure you have the entire history. You can do this by performing a full local bare clone first.

git clone --mirror git://LOCAL_URL/somerepo.git

Then add the remote and push as Timothy pointed out. Though, you probably want to use something other than origin for the remote alias.

git remote add bitbucket ssh://[email protected]/someuser/somerepo.git
git push -u bitbucket --all

This could be used for any Git hosting service. Simply replace the remote URL with anything you'd like.

Upvotes: 11

tyteen4a03
tyteen4a03

Reputation: 1932

From what I know cloning the entire repo and pushing it works. Bitbucket even has the command for you:

cd /path/to/my/repo
git remote add origin ssh://[email protected]/someuser/somerepo.git
git push -u origin --all   # to push changes for the first time

Upvotes: 6

Related Questions