Search code examples
gitlaravelshared-hosting

How to use Git with Laravel separated "backend" and public folders?


There is a Laravel project on shared hosting (HostGator). It means that the backend part of Laravel (everything but public directory) is located in the parent of public_html while its public directory is in public_html/public.

Now, I put Git in the backend part, but I do not know how to include Laravel public directory as Git does not see it.

What is the solution here? Two Git repos then use Git submodule? Not sure how this will work.

Or there is a better solution for such "Laravel on shared hosting" use-case?


Solution

  • You would be better off creating a symlink between your projects public directory and your document root( public_html/public).

    ln -s /absolute_path_to/project/public   /absolute_path_to/public_html/public
    

    This way you only need to have your project directory under version control.