Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to the Power Users community on Codidact!

Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.

Comments on What are best practices for keeping my blog in version control repository (Wordpress in a git repo)?

Post

What are best practices for keeping my blog in version control repository (Wordpress in a git repo)?

+4
−0

What are best practices for keeping my blog in version control?

In particular, I hear that many people use git to version control a Wordpress blog. (a) (b) (c) (d) (e) (f) (g) (h) (i) (j)

That way if something gets deleted or mangled on the public blog (usually the authorized user, me, making a silly accidental mistake, but potentially some computer cracker trying to push malware to the readers of my blog), it can be easily reverted. Ideally, if the production blog server is destroyed, it should be quick and easy to spin up a new server that is indistinguishable from the pre-destruction old blog server to the typical blog reader.

But a Wordpress blog has a bunch of pieces:

  • a SQL database (containing the text I post to the blog)
  • a folder containing photos and media I post to the blog
  • folders containing the base WordPress software, themes, plugins, etc. that generally I don't expect to ever manually edit, and so in principle I don't need to save because I can simply re-download from upstream, but will change every time there's an update.
  • the wp-config.php that (by default) contains the password to the SQL database (and so should not be published in a public gitlab repository).

How many git repositories should I store those pieces in?:

  • Should I somehow store the entire website -- blog and SQL database -- in one big monorepo?
  • Should I have separate git repos, so that every piece is in some repository or another?
  • Should I version-control only things I edit (blog-unique content), and somehow have some tool automatically pull/install/update themes, plugins, etc. available elsewhere?

VersionPress sounds very promising for maintaining a Wordpress blog in a git repository, but as of 2024, VersionPress was still alpha -- not ready for public use. (z)

What's the best practice for posting to a version-controlled Wordpress blog:

  • Use the WordPress web editor on the production website server and then somehow pull those changes to a git repo?
  • Use the WordPress web editor on some isolated local machine or development server or staging website, and then commit those changes to a git repo and then push to the production server?
  • Directly edit the files in the gitlab repo (using the gitlab web text editor), and then "pull" those changes into the production website server?

For a (non-WordPress) simple static website, the answers to those questions seem much simpler:

  • Since .html files correspond 1:1 with reader-visible web pages, all those files can be downloaded directly from the website, so there's no secrets -- I might as well stick every .html file for the entire simple static website in a big public gitlab monorepo.
  • I can use git in the normal way to allow changes to those files in all 3 locations -- on the simple static website, in the gitlab repo (using the gitlab web text editor), and on a local machine with my favorite text editor -- and then push/pull/merge those changes until all 3 locations are back in sync.
History

1 comment thread

Something to consider is that assuming you dump your database out, its probably a large binary file, ... (3 comments)
Something to consider is that assuming you dump your database out, its probably a large binary file, ...
Journeymangeek ‭ wrote about 1 year ago

Something to consider is that assuming you dump your database out, its probably a large binary file, and 'classic' git isn't great for that. I think there's variations like Git LFS that might help. Also there's various backup tools so designing your stratergy around the specific tool in place would be good. I don't remember what I used to use I'm afraid

DavidCary‭ wrote about 1 year ago

I agree that in general SQL dumps often are large binary files, and standard git isn't great for large binary files. However, WordPress database dumps are mostly plain text. And I hear git is great for text files -- it works just as well with a large plain-text fictional novel as it does with a large computer program source code file.

Michael‭ wrote about 1 year ago

MySQL dumps are indeed mostly text, but you end up with pretty long lines that are not ideal for deltas.

Also, the cache table (whose precise name I forget) can be a mess. Sometimes it can even prevent database restoration.