How can I add an empty directory to a Git repository?

后端 未结 30 2672
离开以前
离开以前 2020-11-21 04:52

How can I add an empty directory (that contains no files) to a Git repository?

30条回答
  •  猫巷女王i
    2020-11-21 05:03

    I always build a function to check for my desired folder structure and build it for me within the project. This gets around this problem as the empty folders are held in Git by proxy.

    function check_page_custom_folder_structure () {
        if (!is_dir(TEMPLATEPATH."/page-customs"))
            mkdir(TEMPLATEPATH."/page-customs");    
        if (!is_dir(TEMPLATEPATH."/page-customs/css"))
            mkdir(TEMPLATEPATH."/page-customs/css");
        if (!is_dir(TEMPLATEPATH."/page-customs/js"))
            mkdir(TEMPLATEPATH."/page-customs/js");
    }
    

    This is in PHP, but I am sure most languages support the same functionality, and because the creation of the folders is taken care of by the application, the folders will always be there.

提交回复
热议问题