How do I use .gitignore in visual studio code?

Viewed 37156

So I know this might sound like a noob question but I'm rather inexperienced with GitHub. I want to add a gitignore file to my repository, but I am unable to do so and I don't know how. I want to make sure a file is gitignored My visual studio code is connected with my repository. So I am able to push and pull via visual code.

Greetings,

Parsa & Liyam

3 Answers

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.

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 can press Ctrl+Shift+P on your Visual Studio Code and then search for gitignore. Click the add gitignore option then you are good to go.

Related