Wednesday, June 29, 2016

Working with .gitignore files in Visual Studio

If you work with the .gitignore file in Visual Studio, you will notice that the Visual Studio IDE leaves a lot to be desired when it comes to ignoring files to add to the .gitignore file.

For example, you can only ignore items when they are first added to Visual Studio:


Of course, if you ever want to ignore additional files from Git AFTER  they have been added to the project/solution, Visual Studio offers no built-in method to accomplish this within the IDE!

Fortunately, the famous developer Mads Kristensen provides the .ignore Visual Studio Extension!  https://visualstudiogallery.msdn.microsoft.com/d0eba56d-603b-45ab-a680-edfda585f7f3

After installing this extension, when you then open the .gitignore file in Visual Studio, you will get nice syntax highlighting as follows:



Some of the nice features that it provides is browsing of directory paths in the .gitignore file:


It even provides path information to indicate when file paths that are listed in the .gitignore file do not exist:




Supposedly the grayed out text in the file points to invalid file paths, but, when I point to file paths that DO exist, in some cases, I end up with this instead:


So while this extension fills in a large number of gaps missed by Visual Studio, it has several limitations of its own.  Nevertheless, it is a handy tool to have around when working with your .gitignore files!

No comments:

Post a Comment