Closed RyanMPierson closed 5 years ago
Is there any reason why you wouldn't instead remove the pages from the Grav site (or have a skeleton that comes with no pages)?
The flow of GitSync is to fetch, pull and push and although usually you are correct that it works with Grav pushing pages upstream to an empty repo, because GitSync is two-way really wouldn't matter.
I think this would work best if instead your Grav site was without Pages, especially so considering you want GitHub to be your initial source to pull from. When GitSync does its thing the first time, it would pull the pages from GitHub and since there's no Pages locally it wouldn't try to push anything.
With a solution like Cloudfoundry, if there is a reset or crash event, the app reverts to its original state. Git sync stops working even if you have it set up on initial push (which has to be from an active directory rather than a zip file) so you end up with a site that has no content until a human does the wizard again.
It’s an edge case I know, just throwing the suggestion out there in the event someone wants to make github the boss of the initial sync.
My suggestion would be to delegate to automation all that.
First you need to make sure you get the gitsync config restored so no manual intervention such as going through wizard is required.
Then since the restore brings empty pages back, and since now your config is back, you can automate to run the command bin/plugin git-sun synchronize
(https://github.com/trilbymedia/grav-plugin-git-sync/blob/develop/README.md#command-line-interface).
I’m sure there must be some sort of post hook upon rever to initial state, this is how I would envision the script to run:
I'll give that a shot. Thanks.
In the event that you are setting up Git Sync on an existing repo with an existing pages directory, being able to set GitHub as the "source of truth" to avoid the initial automatic sync from wiping out GitHub's content in favor of the Grav sites is essential.
Especially important in enterprise situations where a lot of sites are on temporary, resetting servers that revert sites back to their original state every X number of days. Setting up the Git Sync again should restore latest content, not remove it. Having this option is a game changer in these cases.