@tobia I understand what you're saying but i would strongly recommend you do not use git for deployments. Git is a versioning tool and not a deploy tool. There are a lot of tools which are better suited for deployment. I myself use Ansible for server provisioning and environment deploys.
Git should be used for what it is build for.. versioning. And you do not want to version 3rd party packages (aka vendor folder) or anything else that is useless to version (like compiled files etc...)