程序中如果引用了空目录,但git提交的代码没有,有时会发生异常。
空目录通常git提交时给忽略了。
有个办法提交空目录即:在每个空目录中新增一个文件.gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore
至于为什么git不能提交空目录原因如下:https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F
Can I add empty directories?
Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.
Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.
You can say "git add <dir>" and it will add the files in there.
If you really need a directory to exist in checkouts you should create a file in it. .gitignore works well for this purpose (there is also a tool MarkEmptyDirs using the .NET framework which allows you to automate this task); you can leave it empty or fill in the names of files you do not expect to show up in the directory.