How to commit only Directory?

This question already has an answer here:

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

  • You can't, there is no point tracking empty directory, there is no such way in git. The history of directory will follow its contents. However you can do what you want, if I am not mistaken, using like .gitkeep or other dotfiles.

    Just create file named .gitkeep in directory that you want to track. So if you want certain history for your directory, then just modify the .gitkeep

    touch mydir/.gitkeep git add mydir/.gitkeep git commit -m "something"

    something will only applied to mydir and .gitkeep file

    链接地址: http://www.djcxy.com/p/7880.html

    上一篇: 我如何复制GitHub上的文件夹?

    下一篇: 如何只提交目录?