When I create a new project on GitHub, the first thing that I add in the initial repository is the .gitignore file (often for VisualStudio) and then I copy that file from another solution on my pc and I commit it.
But time to time, I add some files that I don't want on my repo.
Since a while, I found the perfect solution: create the .gitignore files with the dotnet cli.
Not many people know that the dotnet cli provides a command to create a .gitignore file, practically perfect.
In the root folder of your project, you can launch the command below from your favorite terminal application or from the terminal inside Visual Studio or Visual Studio Code.
dotnet new gitignore
This command will create a perfect .gitignore in your folder with a lot of settings to ignore unnecessary files, not only for Visual Studio but also for Visual Studio Code and JetBrains products.
You can find the latest version of the file at the official repository.
A collection of
This is GitHub’s collection of
.gitignore file templates
We use this list to populate the
.gitignore template choosers available
in the GitHub.com interface when creating new repositories and files.
For more information about how
.gitignore files work, and how to use them
the following resources are a great place to start:
- The Ignoring Files chapter of the Pro Git book.
- The Ignoring Files article on the GitHub Help site.
- The gitignore(5) manual page.
We support a collection of templates, organized in this way:
- The root folder contains templates in common use, to help people get started with popular programming languages and technologies. These define a meaningful set of rules to help get started, and ensure you are not committing unimportant files into your repository.
Globalcontains templates for various editors, tools and operating systems that can be used in different situations. It is…