@dustinmoris is right in his answer, but the fix is not as immediately obvious as the procedure would lead you to believe. So let me explicitly walk you through the process to make sure the files in your .gitignore
file are obeyed by Visual Studio.
1. Create Your Solution & Add It To Source Control
I created a sample MVVM Light XAML Solution and you can see that all the currently untracked files that should ideally be added to the next commit show up with a little green plus next to their icons.
The problem is that the MvvmLight.Win81_TemporaryKey.pfx
file is listed to be added even though all files of type .pfx
are explicitly called out to be ignored in my .gitignore
.
This is even more obvious if I select the solution in the Team Explorer
panel and then select the Changes
button. I see a list of all files pending inclusion on the next commit.
This list contains every file in the Solution, not just the subset specified by the .gitignore
file.
2. Close Visual Studio & Delete the ms-persist.xml
File
It's in a hidden directory so it's kind of hard to find. It should be located at the following path
Solution Directory\.git\ms-persist.xml
3. Re-Open The Solution and Commit Files
You'll notice that it appears as if your solution is no longer under source control because all the icons have lost their green plus signs, but don't worry it's fine.
Head on over to the Team Explorer
panel and then select the Changes
button. Again, you'll see that the project is still being tracked by source control, as well as a list of all files to be added on the next commit. More importantly, you'll notice that your .gitignore
list was properly adhered to this time and all files specified as ignored are no longer listed as pending changes to be added to the next commit. As you can see below, the MvvmLight.Win81_TemporaryKey.pfx
file is no longer scheduled for the next commit!
Hope that helps someone. After all that hassle here is my honest advice:
Learn and use the command line interface since it provides the full range of functionality git offers and has the same interface on all platforms.