LoginSignup
5
5

More than 5 years have passed since last update.

Composer install したらgit submodule化してしまった

Last updated at Posted at 2015-05-22

状況

gitで管理しているレポジトリをgithubにプッシュした際に、webhookを利用して、開発サーバーにソースをアップ(開発サーバーからpull)している。
gitpullは正常に行われているのに、開発サーバーで一部モジュール(今回は cebe/markdown)が読み込めていない。
githubを見てみると、対象のモジュールのフォルダのみがアップされていない。


調査

Composer でPHPのモジュールをインストールした際に、モジュールにgitで管理されているモジュールが含まれていた為、submodule扱いとなり、コチラの意図通りにgit管理出来なくなってしまったとアテをつけて調査。

試しに直接 git add してみる
$ git submodule deinit vendor/cebe/markdown/

No submodule mapping found in .gitmodules for path 'vendor/cebe/markdown'

・・・出来ない。

サブモジュールの削除?
$ git submodule deinit vendor/cebe/markdown/

No submodule mapping found in .gitmodules for path 'vendor/cebe/markdown'

これもムリ。

submoduleのキャッシュがあるらしい。クリアを試す。
$ git rm --cached vendor/cebe/markdown/

error: the following file has staged content different from both the
file and the HEAD:
    vendor/cebe/markdown
(use -f to force removal)

手応えあり・・?


対策

まずは上記のエラーメッセージの導きに従い、-f オプションを付けてみる

git rm --cached -f
$ git rm --cached -f vendor/cebe/markdown/
rm 'vendor/cebe/markdown'

エラーなし。

念のため submodule deinit
$ git submodule deinit vendor/cebe/markdown/

error: pathspec 'vendor/cebe/markdown/' did not match any file(s) known to git.
Did you forget to 'git add'?

git add してないよって言われる。

git add してからやってみる
$ git add vendor/cebe/markdown/
$ git submodule deinit vendor/cebe/markdown/

一応エラーは出ない。

これで $ git status してみると、無事にaddされてる!

実際にはsubmodule化している訳ではないので、submoduleのキャッシュをクリアするのがキーだったぽい。(たぶん)

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