2014年10月21日火曜日

Gitレポジトリの移行方法


gitのレポジトリを移行する方法のメモ。
bitbucketで管理してたレポジトリをgithubで管理したくて調べてみた。
export/importやるのかと思いきや、remoteサーバのurl設定を替えるだけでいいようだ。

まず、今の設定を確認
%>git remote -v
origin https://kentan@bitbucket.org/kentan/test.git (fetch)
origin https://kentan@bitbucket.org/kentan/test.git (push)

次に、remoteレポジトリの変更

%>git remote set-url origin https://github.com/kentan/test2.git%>git remote -v
origin https://github.com/kentan/test2.git (fetch)
origin https://github.com/kentan/test2.git (push)

そして、ソースのpush
%> git push origin master
git logをすると、きちんと過去のcommit logまでpushされており、はじめからgithubにcommitしていたかのように移行できる。