.gitignore not ignoring anything

Any idea?

Steps I’m taking:

git init

In project root, I also add a .gitignore file:

*/Build
*/Binaries/
*/Intermediate
*/Saved
BuildingEscape/Content/StarterContent/
*.VC.db

Add remote upstream:

git remote add origin https....

Commit the ignore

git add .gitignore 
git commit -m 'initial push'

Now here is where the problem arises, this is the only file that can be staged for a commit. Must I manually add each directory to track, I though I could run

git add *

and git would add everything except what’s in the ignore file, but it adds everything regardless.

Solved by running

git rm -rf --cached /path_to_undesirables

For anyone that encounters this, it is very important to add the --cached part, otherwise you’ll delete the local files from your system.

Finally, add the files this way

git add . (rather than git add *)

Now the .gitignore works

Privacy & Terms