LoginSignup
113
122

More than 5 years have passed since last update.

gitリポジトリの複製

Last updated at Posted at 2015-01-20

多分もっとスマートに出来るはずだけど、とりあえず。

  • ローカルではなくリモートから clone することで、余計なブランチが出来ないように修正。(2015/1/20)

リポジトリ例

複製元リモート:user@sample.com:group/hoge.git
複製先リモート:user@sample.com:group/hoge-copy.git
複製先ローカル:hoge-copy/.git

手順

1. リモートリポジトリ作成

2. ローカルの複製先ディレクトリに移動

$ cd hoge-copy/

3. 複製元リモートリポジトリから複製

$ git clone --mirror user@sample.com:group/hoge.git .git

4. リモート先を複製先のリモートリポジトリに変更

$ git remote set-url origin user@sample.com:group/hoge-copy.git

5. 複製先のリモートリポジトリに push

$ cd .git
$ git push --mirror user@sample.com:group/hoge-copy.git

6. ローカルに clone

hoge-copy/ ディレクトリを空にしてからいつも通り clone

113
122
1

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
113
122