If you want to maintain a folder and not the files inside it, just put a ". gitignore" file in the folder with "*" as the content. This file will make Git ignore all content from the repository.
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.
To avoid having to ignore unwanted files manually, you can create a . gitignore file in the working directory of your project. Inside this file, you can specify simple patterns that Git will use to determine whether or not a file should be ignored.
I'm not sure why this doesn't work for you. In case it helps, here's a typical .gitignore file from one of my Visual Studio/git projects:
*.suo
*.user
_ReSharper.*
bin
obj
packages
simply making an entry in gitignore may not ignore files, you may need to commit it. I used the following method and worked for me
git rm -r --cached .
git add .
then
git commit -am "Remove ignored files"
However, this ignores my scripts folder which I included later into the repository.
After a recent update of Visual Studio 2019, the below option was not available. Alternatively, you can also copy the latest gitignore content from the below location. https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore
If you are using Visual Studio then there is a simple way to do this.
It will create a default .gitignore file, which will ignore most of the common folders & files that will be used by the framework/language.
bin
and obj
folders in Windows ExplorerIf you have committed the bin and obj folders previously, adding them to .gitignore will not automatically delete them.
You need to commit deleting these folders with for example
git rm -rf obj
or git rm -rf yourProject/obj
then commit the deletion
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