Search code examples
gitversion-controlgitignoredvcsdrupal-8

How can I git pull ignored files?


For my Drupal 8 installation I want to use the following workflow:

1) On the local machine installs and updates are done with Composer. Composer files are then pushed to Bitbucket.

2) On the remote server I have a staging folder in which I pull the composer files and do a composer install.

3) On the same server I want to have another folder for the production site. Here I clone the staging folder and later pull all its changes.

The problem now is, that Drupal core and modules folders (those installed by Composer) are in gitignore. So they are not pulled from staging to production. How can I track/version control the WHOLE staging folder and pull changes to production? If I delete the gitignore files I suppose they will be pulled again next time from Bitbucket.

EDIT: This article describes a solution, but I don't really understand how it works with this CI server: http://nuvole.org/blog/2016/aug/19/optimal-deployment-workflow-composer-based-drupal-8-projects


Solution

  • You should modify .gitignore and push&pull again in you steps:

    1. On local machine, delete the Drupal core and modules folders in .gitignore and then add & commit & push again.
    2. On the remote server of staging folder, pull the changes.
    3. On the remote server of production site, pull the changes from staging folder.

    option2:

    1. Protect .gitignore file in staging folder, even pull from bitbucket the .gitignore will not be overwirtted as below:

      git update-index --skip-worktree .gitignore

    2. Modify .gitignore file and add some useful files in staging folder.