How can I add an empty directory (that contains no files) to a Git repository?
You can save this code as create_readme.php and run the PHP code from the root directory of your Git project.
> php create_readme.php
It will add README files to all directories that are empty so those directories would be then added to the index.
$object){
if ( is_dir($name) && ! is_empty_folder($name) ){
echo "$name\n" ;
exec("touch ".$name."/"."README");
}
}
function is_empty_folder($folder) {
$files = opendir($folder);
while ($file = readdir($files)) {
if ($file != '.' && $file != '..')
return true; // Not empty
}
}
?>
Then do
git commit -m "message"
git push