A
A
Aidsoid2010-10-29 19:42:24
git
Aidsoid, 2010-10-29 19:42:24

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

It is necessary to ignore the contents of directories /rt-content/usersand , but at the same time do /rt-content/placesnot 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

3 answer(s)
D
Dmitry404, 2010-10-29
@Aidsoid

/nbproject
/rt-content/users/*
!index.html
/rt-content/places/*
!index.html
Try this.

D
Dmitry404, 2010-10-30
@Dmitry404

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.

S
Sergey Antsupov, 2012-04-11
@toor

People tell me how you can force to ignore the .gitignore file ??

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question