Reputation: 7147
I have a .gitignore
file in this directory
/Users/keatooon/pos_dev
I want to ignore all files in this folder and also files in subfolders of this directory /Users/keatooon/pos_dev/apps/POS/ipad/native/www
:
/Users/keatooon/pos_dev/apps/POS/ipad/native/www/default
/Users/keatooon/pos_dev/apps/POS/ipad/native/www/default/app
/Users/keatooon/pos_dev/apps/POS/ipad/native/www/default/dist
/Users/keatooon/pos_dev/apps/POS/ipad/native/www/default/images
/Users/keatooon/pos_dev/apps/POS/ipad/native/www/default/ionic
/Users/keatooon/pos_dev/apps/POS/ipad/native/www/default/index.html
/Users/keatooon/pos_dev/apps/POS/ipad/native/www/skinLoader.html
How to do it?
I've tried to add all these in .gitignore
file but it couldn't work:
apps/POS/ipad/native/www/default/
apps/POS/ipad/native/www/*
Upvotes: 3
Views: 5232
Reputation: 1329822
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:
/apps/POS/ipad/native/www/
(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.
user692942 adds in the comments:
I did not want the full relative path to the route of the repo, so I used
**/folder/subfolder/
which worked.From
gitignore
man page:"A leading
**
followed by a slash means match in all directories. For example,**/foo
matches file or directory foo anywhere, the same as pattern foo.**/foo/bar
matches file or directory bar anywhere that is directly under directoryfoo
."
Upvotes: 5