LoginSignup
1
1

More than 3 years have passed since last update.

Gitでsubtreeを使用して複数のリポジトリを扱う

Posted at

概要

複数のリポジトリをまとめて管理するリポジトリを作成する。
例えば、front, backの二つのリポジトリを、mainリポジトリで管理する。

ディレクトリ構成
main
├── front
└── back

準備

以下三つのリポジトリを用意する

  • main
  • front
  • back

やること (mainにfrontを追加)

1. mainディレクトリに移動

$cd main

2. frontをリモートに追加

$git remote add -f front git@github.com:front.git

3. frontをsubtreeに追加

$git subtree add --prefix=front front main

prefixでディレクトリを指定、frontのmainブランチを追加する。
勝手にコミットされる。

やること (mainにbackを追加)

mainにfrontを追加と同様

subtreeのリポジトリの更新を取り込む

git subtree pull --prefix=front front main

参考サイト

1
1
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
1
1