views:

60

answers:

1

My rails app uploads all users photos to a folder /uploads/photos/. I want to ignore everything in this folder in git except for one subfolder /uploads/photos/default/.

Is this possible using the .gitignore file?

+2  A: 

You can use the prefix !

From the man page

An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources.

# ignore generated html files,
*.html
# except foo.html which is maintained by hand
!foo.html

Although I wouldn't normally store user-generated content in the same hierarchy as my code base/repository.

Brian Agnew