RobertJoseph
RobertJoseph

Reputation: 8158

How to import a Bitbucket repo into my Github account?

I have a large repo on Bitbucket that I need to import into Github. The repo contains a ton of historical information that I do not want to lose. I've googled around and can't find a definitive resource which explains the process. Am I missing something obvious?

Thanks in advance!

Upvotes: 0

Views: 146

Answers (1)

Chris
Chris

Reputation: 137215

Am I missing something obvious?

In many cases simply adding a new remote and pushing to it will do what you want:

git remote add github [email protected]:user/repo.git
git push github master

This will push your master branch to GitHub. You can push other branches in a similar manner, and you can push your tags with git push github --tags.

A more comprehensive option is to use the --mirror option, e.g.

# Add the github remote as above, then
git push --mirror github

From the documentation:

--mirror

Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.

Note that this implies --force, so be careful with it. Some users like to do this from a new bare clone of the remote (i.e. first do git clone --bare [email protected]:user/repo.git, then do the rest of the steps from the newly created bare repository).

Upvotes: 2

Related Questions