I have a C# Visual Studio project in a git repository. I want to ignore the contents bin/Debug
directory but not the contents of the bin/Release
' directory. I've added bin/Debug
to my .gitignore
file, but it doesn't seem to work - it is including the entire contents of the bin
directory. What would the correct entry be to do this?
Right click on those file names you want to ignore from "Git Desktop", then add them to . gitignore file. Here gitignore file will be automatically created. Check in that file to git.
Open Visual Studio and the solution needing an ignore file. From the top menu select Git > Settings. The above will open Visual Studio's Options with Source Control > Git Global Settings selected. From the list on the left select Git Repository Settings and then click the Add button for Ignore file.
Visual Studio GitIn the Git Changes window, right-click any changed file that you want Git to ignore and choose Ignore this local item or Ignore this extension.
You shouldn't have to delete anything. After you added the .gitignore file, run this command to clear the cache, then stage and commit again:
git rm -r . --cached
This typically happens because the .gitignore was added after the files were committed. The .gitignore tells git to ignore untracked files that match, once stuff is committed the ignore will no longer work. One way to fix it is to remove the bin/debug folder (manually through explorer/powershell/bash), then commit the removals. Once that is done the ignores should work as you expect.
git add -A
git commit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With