Git treats folder as file and ignores all subfolders and -files

Since you've done your copy-contents-then-move workaround there's no easy way to test this, but I suspect your tcpdf/ directory contained its own .git/.

Git handles nested directories by creating a special "gitlink" file in the parent repository. When you copied the contents from the tcpdf/ directory into the test directory you could easily have missed the hidden .git/ directory, which means that directory is no longer a nested repository.

With Composer, this could have happened if you used composer require --prefer-source or similar. This is the default if you're using an unstable version.

While some developers like to track the vendor/ directory that Composer creates it's not recommended:

Should I commit the dependencies in my vendor directory?

The general recommendation is no. The vendor directory (or wherever your dependencies are installed) should be added to .gitignore/svn:ignore/etc.

The best practice is to then have all the developers use Composer to install the dependencies. Similarly, the build server, CI, deployment tools etc should be adapted to run Composer as part of their project bootstrapping.

That page goes on to explain why this recommendation exists. I recommend reading the entire page. If you follow this best practice it won't matter if you use --prefer-dist or --prefer-source.

In general, both the composer.json and composer.lock files should be tracked.


Late to the party, as usual, but I stumbled here so others might too.

I had this issue(1) when I accidentally left a .git folder in a sub-folder within my git repo.

I solved it by clearing my local git's cache: git rm -rf --cached . (notice the full-stop at the end!).

See git rm -? for info on the flags.

(1) git thought a folder was a single file