When I pushed my project to github I needed a problem.The structure of my project like this: 
Now I want to upload .gitignore README.md and all of directory d2.
I don't want to write directory in .gitignore because the project not only has d1 I don't want to upload.There so many directory(d3,d4,d5) I don't want to upload.
I want to find a way  that I can ignore all the directory except d2.
I have tried to write .gitignore like this:
*
!/d2/
!.gitignore
!./README.md
But it didn't work.
Do anyone know how to do?Thanks.
 
    