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/.
开发者_JS百科Is this possible using the .gitignore file?
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.
精彩评论