Correct setup for Craft 3 and Git
This article might be of use to you: Setting up a New Craft CMS 3 Project

The DEPLOYMENT section talks about using Composer to install our dependencies, and not checking them into Git. That means a .gitignore that excludes vendor/

This isn't really a right or wrong situation, but rather that the advantages slightly outweigh the disadvantages, imo.

If you want to see this all live in action, you can see the devMode.fm website Github repo which is an OSS example Craft CMS website that powers the devMode.fm podcast.