AUTOMATIC REMOVAL OF .GIT DIRECTORIES IN COMPOSER DEPENDENCIES

If you've adopted a Composer-based Drupal 8 workflow (hopefully using the Drupal Composer / Drupal Project template ) where you keep dependencies in your project repository, then you've no doubt experienced the annoyance of having a .git directory in one of your project's dependencies. This will always happen when you are using the -dev version of a Drupal module. 

If this goes unnoticed and you try to do a normal "git add / commit" workflow for the new module, you'll end up with a somewhat friendly Git message indicating that you now have a Git submodule.

Unfortunately, Git submodules are usually not needed or desired when committing dependencies to the project repository. So, the typical solution is to remove the .git directory of the dependency before performing the "git add / commit".

Luckily, there is an easier way! The Composer Cleanup VCS project .git directories. By adding this as a dependency to your project, any .git directories that result from adding project dependencies will be automatically removed. First, you have to install the Composer Cleanup VCS project using:

composer require topfloor/composer-cleanup-vcs-dirs

Then, every time you use "composer require" to install a project dependency, if there is a .git directory, you will see a message that it has been automatically removed.

Deleting .git directory from /var/www/html/web/modules/contrib/field_redirection/.git

Have Any Project in Mind?

If you want to do something in Drupal maybe you can hire me.

Either for consulting, development or maintenance of Drupal websites.