ufxjgg
Last Updated: February 25, 2016
·
16.84K
· jbowles
9608da7db688950cfd161f51feb648ba

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
Say Thanks
Respond

2 Responses
Add your response

1657
E99a4d45038ce86517c086a958088d50

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 ·
12090
B2c39b28d298baa01772eefeefb949d2

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

over 1 year ago ·
Filed Under