gitignore - allow folder creation but ignore all files inside - can we do it with exclamation mark (!)?

こ雲淡風輕ζ 提交于 2019-12-06 14:23:23

问题


When we push a certain project somewhere, we wish to deploy empty necessary folders too. For example: /runtime/ folder.

However, we must ignore all files inside /runtime/* ;

I'm aware of "the create a useless file inside your empty directories" solution and also, aware of some sort of bash process to make that add of useless files automatic, but isn't there any other way?

I mean:

Is it possible to accomplish this by having on our .gitignore something like:

!/runtime/
/runtime/*

回答1:


No, not currently. The standard trick relies on having a file (somedirectory/.gitignore) in the directory, since git does not stage empty directories, no matter what /.gitignore may say.

It is currently not possible to git add an empty directory.



来源:https://stackoverflow.com/questions/11600188/gitignore-allow-folder-creation-but-ignore-all-files-inside-can-we-do-it-wit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!