Search code examples
databasegituser-interfacegit-remote

Git - fetch changes made to files on remote


I would like first to thank you ! Everytime I get stuck I always find a solution here. So thanks a lot !

But this time I need to ask a question : I am currently building a small website with a web interface where admin can change text saved in the sqlite database. I use git locally and to deploy to the server, and a post-receive hook in the bare repo on the server to checkout files in another directory. This dir is then used by nginx and gunicorn to serve the flask app and the files.

Everything works fine for the moment but I had a question : as the database is stored in a file (sqlite) in another directory than the repo, how can I fetch the changes made on the remote file to my local development repo ? Also the user can upload pictures that are rendered on the website, but how can I fetch them to my local repo. Should I init a repo in the directory I could then fetch ? Or is there another solution ?

I know this question may be silly but I am beginning with databases and web interfaces. Thank you in advance for any help !


Solution

  • As I understand, you have the following setup:

    1. local repo L is pushed to remote R
    2. post-receive on remote clones R to U, which is served by HTTP server
    3. user updates U with new content
    4. you'd like to pull changes from remote U to local L

    I'm assuming that U is a clone of R. You can just fetch changes from U to your local L - no problem here, as all commits made by the user have the same parent commit as you have in your local L. The only troublesome part is to commit changes made by the user in U. You'll probably need to do some scripting there, so if the user uploads some content - say, via ftp - git commit is fired. Repository U must be accessible somehow - ssh seems to be a good idea in this setup.