msvrtan's blog

Transfering remote GIT repos

When we switched from SVN to GIT we decided to have one central repo to ease workflow to developers (extra complexity with everyone having forked remote repo would have been to much at that point). Today I had to copy that main repo to github but it had >50 branches and there was no way I would clone this repo and push branch by branch. I'm just too lazy :) Next idea was to generate a shell script doing this but I was hoping to find some better solution. And I found it. It is '--all' option on push!

There are 2 possibilities how to do it:

1) Create local mirror repo (if you clone push will work only on branches you checked out here)

cd some-folder
git clone --mirror [email protected]/my-main-repo.git
cd my-main-repo
git remote add github [email protected]:my-username/my-new-main-repo.git
git push github --all

2) Directly from bare remote repo</p>

cd my-main-repo.git
git remote add github [email protected]:my-username/my-new-main-repo.git
git push github --all
git remote rm github

I went with idea #2 since our server has much better internet connection then my home desktop but idea #1 is great one if you are not able to ssh yourself to remote server (lets say you want to transfer from bitbucket, assembla or github anywhere).</p>

Just a notice that this is not github feature, it will work everywhere :)