Using git to manage content added via Admin panel?

I am thinking of developing a Grav site for an organization I am a part of. The site would have multiple editors who would only use the web admin panel to add/edit content.

However, myself and another developer will want to use git to keep the site under version control. We know we want to keep the structure/css under version control for sure. We think we want to keep the content under version control as well–in order to roll back errors and maintain a history of the content.

However, I’m not sure how that would be handled. When content is added to the server directly, how can it be added to the git repo? The editors probably can’t/won’t learn git (at least not right away), so editing locally and pushing to a git repo is out. We’re looking at Grav because of the nice admin web panel as a way to add content. Is there a web hook method of making a commit every time the admin panel saves a change?

It would definitely require a custom plugin to integrate git commands into the admin (commit/push/pull). Would be very cool though!

Well, even if there weren’t explicit commands, it would be useful. E.g., editor/writer knows nothing of git. Behind the scenes on every “save”, git did a commit and pushed to repo.

Would be nice to have such a plugin. It would also need to consider possible conflicts when pushing, and decide how to handle those.

The behind-the-scenes Git commands ran is not really the difficulty, that’s just basic commits and pushes, but more as Flaviocopes says how to handle conflicts. With pages this is easy enough - Markdown is just text - but any other media might prove more hazardous. But as it is mainly just text, any editor role should be able to select from the alternatives a regular Git diff presents and choose the best one.

Add in editing with highlighted differences, and the workflow is complete. There are some good libraries for integrating Git with PHP, but all this does require that the Markdown editor can be utilized for displaying differences and revisions without breaking.

Just FYI, we are bringing some ‘simple’ ie, non-git ‘versions’ to Grav admin. Basically it saves a copy of the .md file that you can compare (with visual diff) and roll back to if required.

Useful discussion here. Also, I did find this post about doing something similar using the CMS Statamic. It does seem to account for conflicts. It’s a bit over my head in terms of git scripts/hooks. Would something like this process be possible with Grav?

http://blog.fffunction.co/article/statamic-git

Not really. Those are just standard got commands that work with Grav as is. It’s not any special plugin for stamic. Nothing interesting there :slight_smile:

what kind of best practice would you recommend to do this currently? Im using ssh to git pull latest changes onto the productuion server from a master branch (hosted on Github). I could also manually git commit changes made by users via the admin panel via ssh as well. Would you recommend that workflow?