Ad

Git - Vendor Folder Modifications - .gitignore?

So I have a Laravel installation in which I have modified several Laravel core files in the vendor folder (mainly mail related).

I want everyone who clones the repo to have the same changes obviously. What is the correct way of handling this?

  • Remove the vendor folder from the .gitignore completely and index it all?
  • Keep the vendor folder in the .gitignore and add an exception for the specific files I have modified? (but this will then overwrite these files when a collaborator does composer install, right?)
Ad

Answer

  1. Fork Laravel repo: https://help.github.com/articles/fork-a-repo/

  2. Make a new branch in forked repo, branch name must be prefixed with dev-, e.g. dev-bugfix

  3. Make changes in forked repo, commit them, push them to dev-bugfix branch.

  4. Include forked repo in your composer.json:

{
    "repositories": [{
        "type": "package",
        "package": {
            "version": "dev-bugfix",
            "name": "laravel/framework",
            "source": {
                "url": "https://github.com/<your_github_username>/framework.git",
                "type": "git",
                "reference": "dev-bugfix"
            }
        }
    }],
    "require": {
        "laravel/framework": "dev-bugfix"
    }
}

After this you can pull your custom changes anytime, without having to commit it to your specific project.

Read more about forking and loading packages here: https://getcomposer.org/doc/05-repositories.md#vcs


PS. it's a bad practice to modify vendor package files, try not to do that in future.

Ad
source: stackoverflow.com
Ad