git リポジトリの移行をする
git
Published: 2018-03-04

目的

個人の git リポジトリをチームで使うリポジトリへ移すことが必要になりました。

方法

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

ちょっと補足

$ git clone --help

>   --mirror
>       Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not only maps local branches of the
>       source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec
>       configuration such that all these refs are overwritten by a git remote update in the target repository.
$ git push --help

>   --mirror
>       Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/,
>       refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end,
>       locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the
>       default if the configuration option remote.<remote>.mirror is set.

参考URL