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

后端 未结 30 2457
离开以前
离开以前 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:21

    As described in other answers, Git is unable to represent empty directories in its staging area. (See the Git FAQ.) However, if, for your purposes, a directory is empty enough if it contains a .gitignore file only, then you can create .gitignore files in empty directories only via:

    find . -type d -empty -exec touch {}/.gitignore \;
    

提交回复
热议问题