ScottF ScottF - 1 year ago 143
Git Question

Adding dir to gitignore on windows

I am using smartgit on windows.

I am trying to add some directories in the repo to be ignored.

I am using the following .gitignore, that was recommended for Android Studio android application.

#built application files

# files for the dex VM

# Java class files

# generated files

# Local configuration file (sdk path, etc)

# Windows thumbnail db

# OSX files

# Eclipse project files

# Android Studio
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.


To my understanding, the Build folder should be ignored, but it is not being ignored. In addition the Build\Generated folder is being ignored, but that dir is not even added to the gitignore file.

Here you can see the build folder is not ignored yet the generated folder is.

enter image description here

Answer Source

With this


you're telling git to skip the build directory entirely, so it will automatically ignore any files or directory in that path.

So the generated directory is correctly being ignored.

Now, the only reason (given your gitignore) for intermediate to be included, is that it was already committed on the repo before it became ignored.

If you want to start ignoring it, you need to remove it first, using

git rm -r --cached build/intermediate

As a bonus, if you want to ignore a directory, but not a subdirectory you can do


Here's a more thorough explanation on the subject: .gitignore exclude folder but include specific subfolder

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download