How do I Gitnore all files except two subdirectories?

后端 未结 2 1606
渐次进展
渐次进展 2021-01-07 08:48

How do I ignore all files in a project except two subdirectories? I don\'t want to include all of Wordpress in Git, but I do want to include the customized themes. I have tw

2条回答
  •  梦毁少年i
    2021-01-07 09:20

    Ok I found a way, but this is completely ridiculous! This way will list untracked files if a new file is added.

    # Ignore everything in src/ except wp-content/
    src/*
    !src/wp-content/
    # Ignore everything in wp-content/ except themes/
    src/wp-content/*
    !src/wp-content/themes/
    # Ignore everything in themes/ except for these 2 themes
    src/wp-content/themes/*
    !src/wp-content/themes/chocolat-child/
    !src/wp-content/themes/othertheme
    

提交回复
热议问题