“git push” deletes untracked remote files

喜你入骨 提交于 2019-12-01 23:03:51

You should create symlinks into the OPENSHIFT_DATA_DIR using the deploy action hook, you can view a sample of how to do that in the WordPress quickstart here: https://github.com/openshift/wordpress-example/blob/master/.openshift/action_hooks/deploy

The OPENSHIFT_DATA_DIR persists between deploys, but is NOT shared between gears in a scaled application.

Like most Platform as a Service providers, OpenShift deploys a whole new version of your application each time you push. By default, anything not tracked by Git will not be included in the new version.

You have a couple of options:

  1. OpenShift supports persistent data storage using a special directory:

    The best practice for storing files that must persist across deployments is to use the 'data' directory that is located one level up from your git repository. You can use the $OPENSHIFT_DATA_DIR env variable to reference this on the host. For example:

    If you create a php app called "bunny". The repo's php/index.php file gets deployed to:

    ~/{cartridge name}/repo/php/index.php

    The data directory, then, gets deployed to

    ~/{cartridge name}/app-root/data/

    Therefore from your php/index.php file, if you save a file to "../../../data/blah.txt" it will get placed outside of your repo directory into the data directory.

  2. Store generated / uploaded assets elsewhere.

    This is the approach favoured by PaaS providers like Heroku. Instead of storing user uploads and other generated content on the PaaS server, store it on something like Amazon S3.

Yes, The git repo you're pushing to should not be a repository with a working directory. It should be a bare repository which is initiated with

git --bare init

If you still want to work on the target machine, the best solution would be to use two repositories (one bare and one not), you push to the bare, and then with a hook, pull to to normal. An example for this setup can be found here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!