How to use Git with Drupal 8 when using composer I am working on an OpenSocial project and its installed via composer. I am having a folder structure as below:

 - composer.json   
 - composer.lock   
 - html 
  (Drupal Installation.)
 - vendor 
  (Dependencies)


When creating, should I add the all files including composer.json and vendor to git or just add the content of html directory?

Note In some cases, for example in a normal D8 installation the composer 
 files and vendor directories are in the same directory as Drupal installation.
Short answer: no, you do not need to commit the vendor folder, because the contents are built using composer.lock and composer.json (both should be committed) when running composer install. Some people have to commit vendor due to their hosting constraints and/or having no build process (where the application is built for deployment).

IMO management via Composer with vanilla D8 tarball is very difficult as it lacks the structure to facilitate solid version control, project management and patching workflow that others like Drupal Project or Acquia BLT offer.