Git ignore .git folder

后端 未结 5 1558
梦如初夏
梦如初夏 2021-02-04 09:41

I have a php project that uses composer for package management. One of the packages is another project belonging to the same repo. I have a need to commit my entire vendor folde

5条回答
  •  执念已碎
    2021-02-04 10:27

    The entire vendor folder should be ignored, not just the .git sub-directories. Which packages are used are stored in composer.json and composer.lock which are what you check into version control.

    See: https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md

    If you want to create a reusable package as part of your project, you have two options:

    A) Use Composer to handle another repo

    Add to composer.json...

    {
        "repositories": [
            {
                "url": "https://github.com/l3pp4rd/DoctrineExtensions.git",
                "type": "git"
            }
        ],
        "require": {
            "gedmo/doctrine-extensions": "~2.3"
        }
    }
    

    B) Use a 2nd packages directory

    You can create a packages directory and add it to your autoload paths. This will let you use a single Git repo for all the code (if you want to use two repos, you can use a Git submodule)

    Add to composer.json...

    "autoload": {
        "classmap": ["packages"]
    }
    

提交回复
热议问题