开发者

Git ignore all files in directory expect for specified

开发者 https://www.devze.com 2023-01-20 01:03 出处:网络
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百科

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

精彩评论

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