My team just switched to using acf-json and we have some questions about how to treat the files in terms of a team using git.
The question is basically, should we always commit the .json files when they show as modified and should each team member adhere to a habit if syncing immediately after a pull?
Recently (before I understood that syncing was not automatic) I changed some things in the admin before I synced. Of course that made my âmodifiedâ date newer and syncing was no longer an option. We fixed it by generating new .json files from the production server and synced our local machines to them. Problem solved.
But⦠after I synced, newer .json was created which are effectively identical to what I just imported but with a newer modification date.
Now, if I commit those and another user syncs those wonât the same thing keep happening forever?
For now I will just delete and not commit them but Iâm hoping someone can explain a far more automated, not so hands on workflow when field groups are edited.
Thanks.
You need to do the following to reset everything to normal:
1- Locally, Send ALL ACFs to Trash, then go to Trash and Delete them permanently. ( Data is not deleted, it is stored elsewhere in the posts metadata )
2- On the Production Site, or where the latest functional copy resides, Go to ACF Tools and Export all fields in a JSON.
3- Locally, Import All fields. New local Jsons will be generated that match the Online Config.
—
If the Production site is also having synch problems with the Jsons You need to block access to the config page in production, so that only via JSONs the fields can be updated. (commits)
After the configs are synched, you need to follow this guidelines.
https://www.awesomeacf.com/how-to-avoid-conflicts-when-using-the-acf-local-json-feature/
Yes, the JSON files should definitely be committed to git and be synchronized (if necessary) after every pull. This can get tedious and team members will sometimes forget to do this from time to time.
Looking at
includes/admin/admin-field-groups.php
inside the ACF plugin directory, we see that the manual synchronization requests are being processed around line 295, which means it should possible to automate the synchronization process inside a hook.Doing this would require a lot of caution to prevent interfering with ACF’s field loading… I had trouble with duplicated fields when trying out this and reverted to synchronizing the fields manually (I mainly develop solo)