gitignore - allow folder creation but ignore all f

2020-07-31 00:54发布

问题:

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.



标签: git gitignore