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

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

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

30条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-21 05:10

    The solution of Jamie Flournoy works great. Here is a bit enhanced version to keep the .htaccess :

    # Ignore everything in this directory
    *
    # Except this file
    !.gitignore
    !.htaccess
    

    With this solution you are able to commit a empty folder, for example /log, /tmp or /cache and the folder will stay empty.

提交回复
热议问题