Git – Creating a .gitignore file

Placement of .gitignore depends if the files need to be ignored for just one repo or for all your repos.
For one repo, place it in the root of your repo.

When you create a .gitignore file in an existing repo, or add files that were already in the repo, you have to make sure to remove the to-be-ignored files from the repo.

If you have a test.dll in the root, you have to do

git rm --cached test.dll

Now if you have a lot of files, like you said you can opt for the following option, remove everything from the cache, add it all back (the files in .gitignore will not be added) and commit everything again.

git rm -r --cached .
git add .
git commit -m "Start using .gitignore"

Leave a Comment