.gitignore exclude files in directory but not certain directories

后端 未结 5 1135
刺人心
刺人心 2020-12-12 09:46
application/cache/*
application/cache/folder/*
application/cache/folder/onemorefolder/*

This doesn\'t seem to be working. When I clone the project,

5条回答
  •  Happy的楠姐
    2020-12-12 10:26

    Git doesn't track folders, only files, so if you ignore everything in a folder, Git won't have anything to track. You can add a .gitignore file to each directory (application/cache, application/cache/folder, application/cache/folder/onemorefolder/) with the following contents:

    *
    !.gitignore
    

    Then, you can add those directories, and only the .gitignore file in each directory will get added -- but this means the directories will now be tracked (i.e., created when cloning).

提交回复
热议问题