LoginSignup
8
9

More than 5 years have passed since last update.

Gitリポジトリのホスト先を移行する方法

Last updated at Posted at 2015-02-14

概要

$ git clone --mirror <SOURCE_REPOSITORY_URL>
$ cd <REPOSITORY>
$ git push --mirror <DESTINATION_REPOSITORY_URL>

方法

1. 移行元のリポジトリをclone

$ git clone 移行元のリポジトリ

2. ブランチをcheckout

$ cd リポジトリ名
$ sh git.sh (※)
$ rm git.sh

※git.shの中身

for i in `git branch -r|grep -v HEAD|grep -v master|sed 's:origin/::g'`
do
        git checkout --track -b $i origin/$i
done
git checkout master

3. 移行元のリモートリポジトリの登録削除+移行先のリモートリポジトリの登録

$ git remote rm origin
$ git remote add origin 移行先のリポジトリ
$ git remote -vで確認

4. push

$ git push --all
$ git push --tags

以上です:)

8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9