2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

複数のgitリポジトリを一つのリポジトリにまとめる手順

Last updated at Posted at 2020-02-15

前提

child1, child2があるとき、parentにまとめたい場合。

手順

  1. parentディレクトリを作り、parentに移動する。mkdir parent; cd parent
  2. child1ディレクトリをparentの中に作る。mkdir child1
  3. git管理したいので.gitkeepを作成する。touch child1/.gitkeep
  4. git add -A child1で、バージョン管理されていないファイルも含めて変更があったchild1以下を管理対象に追加。
  5. リポジトリを追加した旨をコミットする。git commit -m "add: child1"
  6. child1をparentのリモートリポジトリに追加し、fetchする。git remote add child1 ~/child1; git fetch child1
  7. マージする。git merge --allow-unrelated-histories -X subtree=child1 child1/master
  8. 不要な.gitkeepを削除する。 rm ~/parent/child1/.gitkeep
  9. child2について、2以下を同様に行う。

参考url

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?