How can I manage git for my strapi app?

System Information
  • Strapi Version: 4.5.4
  • Operating System: macOS
  • Database: MySQL
  • Node Version: 16.19.0
  • NPM Version: 8.19.3
  • Yarn Version: 1.22.19

Hi there, I am a bit confused about the strapi app git repo. I developed my entire cms locally and integrated it with my Nextjs frontend. Everything is working fine, so I deployed cms to the staging server using git. At the staging server, all is working well. Now here is my question, let’s suppose I have to remove a field from my content type collection/single. so for this, I do this locally, I removed that field and test at my frontend, and it is working as expected.

Git detects changes in the schema.json of that content, I add that and commit it to git, and pushed to the repo.

Case 1:
If I pull these changes at the staging server and that schema.json was updated with new changes, that field was removed only from the schema.json, not from the MySQL database.

Case 2:
If I do not pull git changes and remove that field from the admin panel then that field removes from both schema.json and the database. But in this case, git detects changes in the schema.json, and when I try to pull the changes committed locally, here I am getting a git conflict and git pull failed. Because the same file has changed at the staging server that needs to be committed before the git pull.

The same case to creating a new content type. First, I have to build it locally and integrated it with the frontend.

How do I deal with this issue?

So the idea is to have one source of truth.
Which in this case is your local branch.

If you do changes you are right you do them locally then push them to the servers.
The servers pulls the changes and restarts the server and the changes then gets applied to the database.

Everytime strapi “Starts” it does a sanity check for tables and rows and also checks the schema files for changes.

@Eventyret thanks a lot, working as expected.

1 Like