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

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

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

30条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-21 05:15

    The Ruby on Rails log folder creation way:

    mkdir log && touch log/.gitkeep && git add log/.gitkeep
    

    Now the log directory will be included in the tree. It is super-useful when deploying, so you won't have to write a routine to make log directories.

    The logfiles can be kept out by issuing,

    echo log/dev.log >> .gitignore
    

    but you probably knew that.

提交回复
热议问题