Search code examples
phpgitcomposer-phpgit-submodules

How to add files to main repository when using composer?


In my PHP project I use composer. For some reasons (stupid, but it's not depending on me) I must store all project files in a git repository, including "vendor/" files fetched by composer. I've removed "vendor/" from the .gitignore file, but some modules (like https://github.com/RWOverdijk/AssetManager) are treated as submodules - and they are not being added to the repository (git add ignores them).

What do I need to do, to force addition?


Solution

  • You can use the following commands:

    # remove `.git` folders recursively
    find vendor -type d -name '.git' -exec rm -rf {} \;
    # Add the vendor folder
    git add vendor
    

    Probably it would be better to persuade your boss that composer isn't meant to work like that.