やりたいこと
- repo init 、repo syncを使用して、Git Hubに載せている複数のリポジトリを一括取得したい。(今回は2つのリポジトリを取得)
準備
とりあえずリポジトリを3つ作ってみる。
取得するリポジトリ①
取得するリポジトリ②
リポジトリ③(マニフェストファイルを格納)
manifestというリポジトリを作成し、マニフェストファイル(manifest.xml)を格納。
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch="https://github.com/" name="github"/>
<project path="test_repo/test_repo_1" name="my_account/test_repo_1" remote="github" revision="main"/>
<project path="test_repo/test_repo_2" name="my_account/test_repo_2" remote="github" revision="main"/>
</manifest>
"remote"でgithubを指定、
"project"で取得するリポジトリを指定しています。
リポジトリ取得
repo init / sync のオプションは公式ドキュメントを参考にしました。
repo init
repo init -b main -u https://github.com/my_account/manifest.git -m manifest.xml
repoの初期化コマンド。実行した階層に.repoディレクトリを作成する。
repo sync
repo sync -c -q
.repoが作成されたディレクトリで実行する。
manifest.xml内で指定したリポジトリを一括取得する。
実行結果
----------------------------------------------------
$ ls -la
total 16
drwxr-xr-x 4 user user 4096 Jun 10 02:02 .
drwxr-xr-x 6 user user 4096 Jun 10 01:59 ..
drwxr-xr-x 7 user user 4096 Jun 10 02:01 .repo
drwxr-xr-x 4 user user 4096 Jun 10 02:02 test_repo
----------------------------------------------------
$ tree
.
└── test_repo
├── test_repo_1
│ ├── bar.txt
│ └── foo.txt
└── test_repo_2
├── hoge.txt
└── test.txt
3 directories, 4 files
----------------------------------------------------
"test_repo"ディレクトリが作成され、"test_repo_1","test_repo_2"リポジトリが一括で取得できた。