This is a useful technique, and I use the following .gitignore; maybe it’s helpful:
/vendor/**/.git/