When you create a file in your repository named .gitignore, Git uses it to determine which files and directories to ignore before you make a commit. A .gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.
GitHub maintains an official list of recommended .gitignore files for many popular operating systems, environments, and languages in the github/gitignore public repository. You can also use gitignore.io to create a .gitignore file for your operating system, programming language, or IDE.
1. Open Visual Studio Code
2. Right click on project Explorer
3. Click New File
4. Name the file as .gitignore
5. Double-click the file and open it
6. Enter the folder or file type which you want to ignore while check-in
7. Save changes
You are Done!!!