Last Updated: February 25, 2016
·
18.23K
· jbowles

Move repo from bitbucket to github

The short way...

Edit the [remote "origin"] branch url, create github repo, and push:

# this
[remote "origin"]
   url = ssh://git@bitbucket.org/jbowles/learning-nodejs.git
   fetch = +refs/heads/*:refs/remotes/origin/*
#to this
[remote "origin"]
   url = git@github.com:jbowles/learning-nodejs.git
   fetch = +refs/heads/*:refs/remotes/origin/*

   $git push -u origin master

The long way

Open .git/config and delete [remote "origin"] branch:

$vim .git/config

So that this:

[core]
   repositoryformatversion = 0
   filemode = true
   bare = false
   logallrefupdates = true
   ignorecase = true
[remote "origin"]
   url = ssh://git\@bitbucket.org/jbowles/learning-nodejs.git
   fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
   remote = origin
   merge = refs/heads/master
   rebase = true

looks like this

[core]
   repositoryformatversion = 0
   filemode = true
   bare = false
   logallrefupdates = true
   ignorecase = true
[branch "master"]
   remote = origin
   merge = refs/heads/master
   rebase = true

Create repo in Github and when it comes to time to add the remote origin do:

$git remote add origin git@github.com:jbowles/learning-nodejs.git

and your .git/config should look like this:

[core]
   repositoryformatversion = 0
   filemode = true
   bare = false
   logallrefupdates = true
   ignorecase = true
[branch "master"]
   remote = origin
   merge = refs/heads/master
   rebase = true
[remote "origin"]
   url = git@github.com:jbowles/learning-nodejs.git
   fetch = +refs/heads/*:refs/remotes/origin/*

Then push:

$git push -u origin master

2 Responses
Add your response

Or with even less hassle:

git remote rm origin
git remote add origin git@github.com:username/project.git
git push -u origin

over 1 year ago ·

This won't transfer wiki's/issues/comments etc... just the repo and history

over 1 year ago ·