2

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/*
user1872384
  • 6,626
  • 10
  • 54
  • 96

1 Answers1

4

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.

Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755