.gitignore exclude files in directory but not certain directories

后端 未结 5 1136
刺人心
刺人心 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条回答
  •  再見小時候
    2020-12-12 10:27

    There is another perhaps cleaner way to do this. Rather than having sub .gitignore files in the folders you want to keep. You can put this in the root .gitignore as follows:

    application/cache/*
    application/cache/folder/*
    application/cache/folder/onemorefolder/*
    !*.gitkeep
    

    Now just create and commit empty .gitkeep files into the directories as listed above. The folder will then be tracked with those .gitkeep files but none of the contents will be tracked.

提交回复
热议问题