8 Ways to Sync Git Repositories with WordPress
Have you ever heard the saying, “a developer’s work is never done”? No? Okay, maybe I took some liberties with the original quote, but you get what I’m saying. Basically, there is never a good time to rest on your laurels.
Like, move all your web development work over to a local server. Taking it one step further, you should be developing on a local server and storing master copies of your work on Git. There are a number of reasons you should do this:
- Git repositories (like GitHub and Bitbucket) work as an additional backup for your site’s files.
- They also make it easier—and safer—to collaborate on web projects with multiple parties since you can all simultaneously work on them without having to worry about the latest changes being preserved.
- And, of course, there’s the version control aspect of it. These repositories create a record of everything that has happened on your project’s files and folders, from initial creation to subsequent edits.
- Individuals involved in the projects can also contribute notes that explain what was changed and why, making this a great place to communicate.
- In addition, Git repositories give developers the ability to test out hypothetical changes to their websites without affecting original sources files or the live instance of the site.
Here’s the problem with adding two new workspaces to your process: if they don’t flow seamlessly into one another, that means more manual work for you since you’ll need to copy everything from the local server over to Git, and then from Git over to your website. Or the other way around. But, of course, this is web development we’re talking about and web developers are, if anything, resourceful.
Today, let’s talk about the resources available to streamline this process for you. It would be a shame to pass on the opportunity to improve the efficacy of your process simply because it results in too much additional work. There are always ways around this, especially when you develop sites for WordPress.
Syncing Git Repositories with WordPress
So, you like this idea of developing websites or testing changes for your website in a better environment and you also like the idea of a Git host managing the storage and version control of your project. But you want to know how exactly you’re going to get all the work you do outside of WordPress back into the CMS.
Well, there’s a manual way to do this and then there are plugins. The manual way can cause some issues—like not bringing over all of the updated files or creating a conflict with a change someone else made on the live server. Regardless, some of you might still prefer the hands-on approach, so I’m going to include that option below as well.
Here are 6 ways to sync your Git repository with your WordPress site, and start developing websites more efficiently today.
Method #1. Manual Syncing
Most web hosts these days include SSH/shell access for your website. Once you’ve enabled SSH access, you can then use command lines to pull project files from your Git repository into WordPress. Or you can manually copy files from Git and use SFTP to replace them on your live server. As mentioned above, that may be a risky move if you don’t update the correct file, if conflicts arise, or some other error is thrown that breaks your site, so proceed with caution.
Method #2. GitHub Updater Plugin
This plugin was specifically created for WordPress plugin and theme developers. So, if your source theme or plugin files exist on GitHub, Bitbucket, or GitLab, and you want to seamlessly transfer updates to your assets from the repository to WordPress, you can do so with this plugin that automates the process.
1.6 million WordPress Superheroes read and trust our blog. Join them and get daily posts delivered to your inbox - free!
Method #3. PhpStorm IDE
In general, PhpStorm is an IDE, an integrated development environment that developers can use to write, test, and save code within a singular platform and UI. However, the makers of PhpStorm have recognized a need to save their work outside of the IDE, and Git repositories are the natural go-to for that. So while this tool won’t sync with WordPress, it will at least enable developers to create pull requests. for easy saving of new code or coding updates.
Method #4. Revisr Plugin
The main driving force behind the Revisr plugin is to help developers create a better version control system from within WordPress, most likely when you’re using staging or test sites on sub-domains to make updates. However, this plugin can also be used to pull in changes from a Git repository.
Method #5. WordPress GitHub Sync Plugin
The WordPress GitHub Sync plugin doesn’t just work for WordPress, it also works with Jekyll sites. That being said, the only sort of version control and Git repository syncing you can do with this pertains to written content (which is why it’s ideal for Jekyll). So, if you’re developing or managing a site or blog that’s heavy on the written word and with multiple authors working on the content, this plugin will help you maintain that version control and sync the Git repository to your site.
Method #6. WP Migrate DB Plugin
There is both a free and premium version of the WP Migrate DB plugin available for use, but I’d suggest you start with the free one once you’re sure you actually need it.
Unlike plugins that handle an actual sync between your Git repository and WordPress site, this one solely works to pull in a SQL database file. Why would you want to use this plugin? Well, you wouldn’t want to use it to automate your sync, but you could use it to cut down on time spent using the manual option mentioned above.
Method #7. WP Pusher Plugin
The WP Pusher plugin is exactly what you need to automate the syncing of a Git repository with WordPress. In fact, it takes care of all the guesswork so that whenever a change is made in Git, it automatically moves over on its own. This works for website development as well as plugin and theme development, too.
And, if you run a multi-site or have multiple projects going concurrently, WP Pusher has plans to account for those multiple instances.
Method #8. Beanstalk App
This app instead enables developers to write and save all their code and files within Beanstalk, essentially merging the first two pieces of the puzzle into one. Beanstalk then syncs directly with WordPress. If you want to use this app, be sure to read their guide on how to use it with WordPress.
Being the best web developer doesn’t just mean that you create the most beautiful, the fastest, or the most popular websites. You still need to write clean code, cover all your bases, and work efficiently.
If you haven’t adopted local server development and Git repository version controlling into your process yet, now is the perfect time to do so. Just make sure you have a safe and easy way to sync those off-CMS changes back into WordPress.