user1872384 user1872384 - 14 days ago 5x
Git Question

Gitignore for all files in folders and subfolders

I have a

file in this directory


I want to ignore all files in this folder and also files in subfolders of this directory



How to do it?

I've tried to add all these in
file but it couldn't work:




The rule to remember with gitignore:

It is not possible to re-include a file if a parent directory of that file is excluded.

I want everything in /Users/keatooon/pos_dev/apps/POS/ipad/native/www to be ignored.

That would then simply be a /Users/keatooon/pos_dev/.gitignore with:


(note the trailing slash, to ignore the folder content)

Make sure the content of that folder was not already tracked (because in that case, any modification would still show up in the git status)

Check that a file is correctly ignored by that rule with:

git check-ignore -v /Users/keatooon/pos_dev/apps/POS/ipad/native/www/<aFile>

If not, type:

git rm -r --cached /Users/keatooon/pos_dev/apps/POS/ipad/native/www/
git add .
git commit -m "remove apps/POS/ipad/native/www from repo"

The files on the disk will remain, but you will record in the history of the repo the deletion of www/, whose content will then be ignored.