Git Ignore everything in a directory except subfolders

前端 未结 3 525
陌清茗
陌清茗 2020-12-29 01:58

This is my folder structure:

data/
    .gitignore
    uploads/
        .gitignore

I would like to commit the folders but not the files insi

3条回答
  •  离开以前
    2020-12-29 02:08

    The solution is quite easy, add !*/ to the .gitignore files and only files in the current folder will be ignored

    # Ignore everything in this directory
    *
    # Except this file
    !.gitignore
    # Except folders
    !*/
    

提交回复
热议问题