开发者

Git ignore all files in directory expect for specified

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜