Who Should Be Using Version Control For WordPress Development?


Posted On:

As someone who often makes mistakes, has an imperfect memory, and writes more than one line of code for every project I work on, I couldn’t live without version control. Honestly, I started using my own bad version of version control on the first big WordPress custom theme project I did.

On that project, I had a whole folder of files with names like “page.php-10:15PM-tuesday” or “page.php-before-changing-loop”. That unwieldy system helped me undo the mistakes I was making on the live site I was FTPing things at in desperate hope they would work.

Discovering proper version control systems, specifically git allowed me that confidence, to experiment, in a system that was actually sensible. Best of all, Git also has helped facilitate collaboration with others, the most rewarding part of what I do.

A Note On Magic Bullets

I write a lot, on this site, and around the internet, about ways to make your life easier, and do better when building things with WordPress. Nothing that I suggest is a simple magic bullet, install this and achieve epic victory.

None of them are too hard to learn, but will take a little bit of work. I know that kind of work can be frustrating, as it will slow you down a bit at first, but see it as an investment to save countless hours of time in the future.

Also, keep in mind that a tool is just a tool. I’m about to suggest some very specific tools for solving a particular problem. Are there other tools that do something similar or the same thing? Yes. Explore your options.

What Version Control Is & Why You Need It

Version control, a system that tracks changes to any type of data, WordPress post content, theme files, WordPress itself, etc. is one of the most important tools to implement in your workflow, no matter what kind of work you do.

Word processors, such as Microsoft Word and Google Docs have version control systems — “track changes” built into them. The WordPress post editor has revision tracking, though many people may need more granular control, which the post forking plugin can provide.

Who Should Use It?

Any files that are unique to your site, the child theme, any custom plugins, etc, need to be under version control. Version control isn’t just the ultimate undo button, but it creates a record of what has changed, and makes collaborating with others easier. Version control systems, such as Git, track every change, what happened, when and by who.

Even if you are just writing a little CSS for your site,  you need to have version control for two important situations. The first is when you spend all afternoon making radical changes, and they turn out terrible. Without version control you are stuck trying to reconstruct the way it was. With version control, you simply “revert.”

The other situation is you do a ton of work and show it to your client who says, “I love it, but I like the way the header was before.” Without version control you’re stuck trying to figure out what is different about the header. With version control, you can see exactly what changed when and undo the changes you don’t want.

SourceTree and other GUI tools make this easy to do. They also help visualize your branches. By the way, one awesome feature of SourceTree is that you can right click any file, in any commit, and open it as it existed when you made the commit.

Screenshot of SourceTree Git GUI Tool
Screenshot of SourceTree Git GUI Tool

Git, the best type of version control system for code, is easy to learn, especially when you use a GUI tool like SourceTree. Getting used to using Git, and working the process of making regular commits, with meaningful commit messages take time, but the first time it saves your butt or reduces the friction to working with others, it will be worth it.


Git Can Be  A Part Of Your Deployment Strategy

If your development workflow involves more than on environment — production, staging, local development, then Git can be a part of your workflow for moving between environments. Since a Git repo can be cloned into multiple environments, you can use it to create exact copies of your files in multiple places.

How big of a role Git plays in your deployment process is a difficult question, which is tied up in the question of what you will place under version control. Some people, including me at times, will put a whole WordPress site under version control. This means you are “double version controlling” WordPress and your plugins and themes. I’m not a huge fan of this, but it works.

Other times, if you are just making a child theme for a site, that is all you need in the Git repo. Other times you need multiple git repos, and a dependency management system such as Composer.

This is a huge topic, which you should be thinking of when you start using Git, but deserves its own article. That article, like winter, is coming.

How To Learn Git

If you’ve never used Git before, it may seem a little daunting. While I recommend SourceTree, the Github desktop app might be a better “starter” GUI tool. It’s how I started, and I found the visualizations they offer of the Git tree very useful.

I’ve written a few guides to version control in WordPress, that I recommend for those getting started:



2 thoughts on “Who Should Be Using Version Control For WordPress Development?”

  1. I completely agree about the importance of version control. The tricky bit is how this works for small projects, for example if you are just making some tweaks to the code on a WordPress website. I know WordPress developers who will charge an extra hour to set up Git on each project, which is fine for complete projects but seems overkill for smaller tweaks. We have a flexible approach to version control for this reason.

  2. I was introduced to perhaps the very first version control system for software back in the fledgling UNIX days – it was called “SCCS” – Source Code Control System. This was ALL command-line stuff, and the primary operator for SCCS was the command “get” – with all its options to get specific release levels. Perhaps the basis for “Git”?

    Ah, yes – back in the day when Bell Laboratories was more than phones. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *