Answer the question
In order to leave comments, you need to log in
Make git ignore everything in a directory except for one file?
How to make git ignore all contents of a directory except for one file?
At the root of the project is the file .gitignore
, its contents are:
$ cat .gitignore <br/>
/nbproject<br/>
/rt-content/users<br/>
/rt-content/places<br/>
!/rt-content/users/index.html<br/>
!/rt-content/places/index.html
/rt-content/users
and , but at the same time do /rt-content/places
not ignore files inside these directories. My version doesn't work, what am I doing wrong? /rt-content/users/index.html
/rt-content/places/index.html
Answer the question
In order to leave comments, you need to log in
/nbproject
/rt-content/users/*
!index.html
/rt-content/places/*
!index.html
Try this.
And one more thing, the ignoring rules for files that you need to ignore, but other "users" of the repository may not have them (for example, as in your case, IDE settings files), it is better not to add them to .gitignore, but place them either in .git /info/exclude or in git config setting core.excludesfile.
People tell me how you can force to ignore the .gitignore file ??
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question