开发者

Best practice for ignoring files within a folder with GIT

开发者 https://www.devze.com 2023-02-03 11:14 出处:网络
I\'m just looking for some advice on the best way to manage the following situation with git. my project has a folder called \"photos\" that users can upload images to.

I'm just looking for some advice on the best way to manage the following situation with git.

my project has a folder called "photos" that users can upload images to.

I have a version of the project running locally and I am adding images to this folder for testing purposes.

When I push to the live server I want the "photos" folder to get pushed but not the images within it. Also when users add images to the "photos" folder on the l开发者_运维问答ive server I want GIT to ignore them.

I know I need to use Git Ignore but I'm unsure what the best way to do this is.

Should I just add "photos" to the git ignore file and then manually create the "photos" folder on the live server?

Thanks in advance.


echo '*' > photos/.gitignore
git add -f photos/.gitignore

Git does not support empty directories, but standard practice for a directory is to create a .gitignore file inside it. The * entry causes git to ignore anything inside the directory (even the .gitignore file itself, hence the add -f to override that).

0

精彩评论

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

关注公众号