creating repository with gitignore

This question already has an answer here:

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

  • As Git FAQ answers,

    Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.

    Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.

    The only way is to create a empty file .keep just meant for adding the directory in Git staging area. This trick is used by Rails too.


    I would achieve this by adding an empty hidden file in the directories. Like ".path" and in the gןt ignore file specify the file extensions that you want to ignore in those paths. For example:

    /assets/img/*.jpg
    

    That way you add the .path file witch is actually nothing and all the rest is ignored.

    Let me know if it solves your issue.

    Just remember that git is tracking content. Not directories. So keep that in mind when you want paths to be "tracked"

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

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

    下一篇: 使用gitignore创建存储库