LoginSignup
3
5

More than 3 years have passed since last update.

サブモジュールを含むリポジトリのGit cloneは--recursiveオプションが必要

Last updated at Posted at 2020-07-04

TL;DR

サブモジュールを含むリポジトリは単純にgit cloneするだけではサブモジュールはcloneされません。
その時は --recursive オプションを追加することでまとめてcloneできます。

git clone --recursive https://github.com/hoge/fuga.git

サブモジュールを含むリポジトリ QMK Firmwareを1発でCloneしたい

自作キーボード Helix のFWとしてQMK Firmwareを使っています。
ビルドガイド従わず手癖でgit cloneをしました。
(ビルドガイドをさらっとしか読んでいなかったので見逃していました)

# ビルドガイドの手順
git clone --recursive https://github.com/qmk/qmk_firmware.git

# 手癖の手順
git clone https://github.com/qmk/qmk_firmware.git

で、ビルドをすると次のようにLUFA/makefileがないとエラーになります。

tmk_core/protocol/lufa.mk:14: lib/lufa/LUFA/makefile: No such file or directory
/bin/sh: avr-gcc: command not found
make[1]: *** No rule to make target `lib/lufa/LUFA/makefile'. Stop.
make: *** [helix:led_test] Error 1

LUFAはサブモジュールなので--recursiveオプションなしだとcloneはされない仕様です。だからビルド時にLUFAがないと怒られたというわけです。

その時は直接LUFAをcloneして該当のディレクトリに配置して無理やりビルドを通しましたが、改めて調べてみるとサブモジュールをまとめてcloneする--recursiveオプションがあることを知りました。

どんなリポジトリでも初回cloneの時は--recursive必須というやり方をしたらダメなんでですかね。もしくは--initialcloneみたいな初回専用のオプションとかあればわかりやすくていいのかな。

3
5
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
3
5