Search code examples
gitvisual-studiogitignore

How to add specific file to .gitignore in Visual Studio solution?


I want add specific file to be not tracking by git. Im using default Visual Studio .gitignore that was generated by Visual Studio while making solution.

Now, i have a file that i dont want to be tracked. I tried to add this file to .gitignore:

/TaskManager-wpf/Services/UrlBuilder.cs

but when i paste it into last line of .gitignore it not work and when i change this file, Visual Studio TeamExplorer still tracking this file and want to commit changes on it.

My question is, how to add specific code .cs file into .gitignore?


Solution

  • .gitignore will prevent untracked files from being added (without an add -f) to the set of files tracked by git, however, git will continue to track any files that are already being tracked.

    you can see the solution here