.gitignore configuration problem

when I want to implement git Synchronize, I ignore the folders under node_modules except @ wang, that is to say, keep the @ wang folder. How should I configure .gitignore files

Apr.09,2021

in fact, this kind of problem is already written in the git document, but you may not read the document or ignore it.

.gitignore official document

Example to exclude everything except a specific directory foo/bar (note the / *-without the slash, the wildcard would also exclude everything within foo/bar):
$ cat .gitignore
    -sharp exclude everything except directory foo/bar
    /*
    !/foo
    /foo/*
    !/foo/bar

knowing this, come back to your question

node_modules/
// 
!node_modules/@wang

but you may have ignored the node_modules as a whole before, resulting in adding the exclusion file now, which has no effect.

look at the document again at this time. It is said that you can refer to:

SEE ALSO
git rm official documentation

if you look at it, you can see:

// -r 
// --cached 
git rm -r --cached node_modules/@wang
git status
// 

then you will find that the node_modules/@wang folder is ready to submit.

if you think there is something wrong with English documents, you can download tools such as translation plug-ins, or search for Chinese documents.

or you can search for keywords such as Bing search , search git to exclude a folder under the ignored folder if you can't surf the Internet scientifically.


here is a hole, flip under Baidu, this article can solve your problem

Menu