Search code examples
gitdeploymentgit-deploy

How to ignore the content of folder without deleting when deploying via git


My project has a folder called 'images', its content depends on user uploads, so the content from the development environment is different of the production one.

When a commit is merged and deployed to the host via git, it automatically deletes all the content in the production. I tried using .gitignore with images/* to ignore all the content, but the git interpreters as if the content was deleted.


Solution

  • its content depends on user uploads

    That is a runtime data, no a source code base element.

    In your source code, you should record image as a symlink (stored in a Git repository as a blob with a path to an external folder)

    That way:

    • image has no merge problem
    • the external path to the actual image/ folder content is not impacted by the Git repository being merged or checked out.