How do I use .gitignore in visual studio code?

Vscode 1.46 is adding some automated help in generating a .gitignore file when you publish to github. From v1.46 release notes:

Publish to Github: Generate .gitignore

It's now possible to generate a .gitignore file when publishing a workspace to GitHub. When publishing a workspace to GitHub, you are prompted to select which files to include in the repository.

generate a .gitignore file


You may go to File > New File at the root of your git repository (same directory as where your .git hidden folder is in). Then add all the directories/file that you want to be ignored into that new file and save it as .gitignore. (You can save as a plaintext file and just name it .gitignore within VS Code.