With or without .gitignore in VSCode's OCaml extension

So far I never used the .gitignore directory in my git setup, I only used git add as needed.

Now I’m trying to learn github inside Visual Code Studio with hackwaly’s OCaml extension. The problem I encounter immediately is that by default
VSCode wants to copy all the files in my project to the remote repository, including the .cmo, .cmt files etc, which I obviously don’t want.

Is it mandatory to put all the .cmo, .cmt files into .gitignore ?

I don’t know VSCode, but a .gitignore file for an OCaml project often looks like this:

/_build
/*.install
.merlin

The above assumes you’re using jbuilder. The first line ignores the entire _build directory, which is where jbuilder (and other OCaml build systems) put their output files. The second line ignores all .install files at the root of your project and all .merlin files anywhere, since jbuilder auto-generates these too.