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

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

    touch .keep
    

    On Linux, this creates an empty file named .keep. For what it's worth, this name is agnostic to Git. Secondly, as another user has noted, the .git prefix convention can be reserved for files and directories that Git itself uses for configuration purposes.

    Alternatively, as noted in another answer, the directory can contain a descriptive README.md file instead.

    Either way this requires that the presence of the file won't cause your application to break.

提交回复
热议问题