'How do I use .gitignore in visual studio code?
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
Solution 1:[1]
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.
Solution 2:[2]
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
.gitignorefile when publishing a workspace to GitHub. When publishing a workspace to GitHub, you are prompted to select which files to include in the repository.
Solution 3:[3]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Aldric |
| Solution 2 | Mark |
| Solution 3 | Dada |

