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.
You may use the following .gitignore
.
/*
!/d2/
!.gitignore
!README.md
*
ignores all files in directories in all depth, while /*
only ignores the files and directories under the root level.
By the way, if you want that it still works with *
, you need to add !/d2/**
as follows.
*
!/d2/
!/d2/**
!.gitignore
!README.md
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.