Luce Carter Logo

  • open-source
  • git
  • .net
  • code
  • software dev

Advent of Tips: #1 - Creating a gitignore file for your .NET projects

I don't know about you but when I start a new project, one of the first things I do is call git init and create a repo to store it in GitHub.

But out of the box, a lot of files and folders will get included that we don't want or need. It adds bloat to the size and can often include stuff like build artefacts that will be regenerated on build anyway.

This is where a .gitignore file comes in. It tells Git what files and folders we don't need and it will simply ignore them. However, what you ignore will change depending on language and frameworks right? So where do you start?

Well if you are creating a .NET project, you are off to a winner! If you have the .NET SDK installed (which you should if you create .NET Core/.NET 5.0/,NET 6 projects), you have what you need already.

From the root of your project where you created the git repo, simply enter the following in your command-line tool of choice:

dotnet new gitignore

This will automatically create an optimised gitignore file with the common files and folders that are ignored for .NET projects. Winning!

Emote of Luce making a heart gesture

Luce Carter

Dev 🥑 at MongoDB | Microsoft MVP | Twilio Champion | I help developers build confidence and battle Impostor Syndrome, one line of code or story at a time | She/Her