Here's part of the contents of my .gitmodules
file:
[submodule "src/static_management"]
path = src/static_management
url = git://github.com/eykd/django-static-management.git
[submodule "external/pyfacebook"]
path = external/pyfacebook
url = http://github.com/sciyoshi/pyfacebook.git
However, .git/config
only contains the first:
[submodule "src/static_management"]
url = git://github.com/eykd/django-static-management.git
2 番目のサブモジュール ( external/pyfacebook
) は、別の開発者によって機能ブランチに追加されました。現在、開発を引き継いで、機能ブランチをチェックアウトしました。ただし、Git はサブモジュールをプルしません。次のことを試しました:
git submodule init
git submodule update
git submodule update --init
git submodule sync
- からすべてのサブモジュール定義を削除し
.git/config
、 を実行しますgit submodule init
。既存のサブモジュールのみがコピーされ、新しいサブモジュールは無視されます。 - に新しいサブモジュール定義を
.git/config
手動で入力し、を実行しますgit submodule update
。 以前から存在していたサブモジュールのみが更新されます。
さまざまな組み合わせがありますが、git は.git/config
の新しい内容に基づいて更新することは.gitmodules
なく、external/pyfacebook
フォルダーを作成してサブモジュールの内容をプルすることもありません。
何が足りないのでしょうか? 手動介入 (サブモジュール エントリを手動で追加する.git/config
) は本当に必要ですか? また、その理由は何ですか?
編集:手動介入は機能しません。新しいサブモジュール エントリを手動で追加しても.git/config
何も起こりません。新しいサブモジュールは無視されます。
ベストアンサー1
私も同じ問題を抱えていました。.gitモジュールファイルはコミットされましたが、実際のサブモジュールのコミット (つまり、サブモジュールのコミット ID のレコード) はコミットされませんでした。
手動で追加するとうまくいくようです - 例:
git submodule add http://github.com/sciyoshi/pyfacebook.git external/pyfacebook
(.git/config または .gitmodules から何も削除しなくても)
次にコミットして ID を適切に記録します。
この実用的な回答にさらにコメントを追加します。またはgit submodule init
がgit submodule update
機能しない場合は、上記のようにgit submodule add <url>
すればうまくいくはずです。これをクロスチェックするには、
git config --list
コマンドの結果に、プルするサブモジュールのエントリが取得されるはずですgit config --list
。構成結果にサブモジュールのエントリがある場合は、通常どおりgit submodule update --init
サブモジュールをプルするはずです。この手順をテストするには、サブモジュールの名前を手動で変更してから、サブモジュールを更新します。
mv yourmodulename yourmodulename-temp
git submodule update --init
git status -u
サブモジュールにローカルの変更があるかどうかを確認するには、 ( サブモジュールの変更を確認する場合 ) またはgit status --ignore-submodules
( サブモジュールの変更を確認したくない場合 )を使用します。