WordPress is an open-source and developer-friendly software. Besides using it to create and manage a website, you can also explore the source code to create your own projects like plugins or themes.
When creating a project, it can be overwhelming to track every change made, especially when you want to fix some problems in the process. Fortunately, you can manage your tasks with the help of Git and GitHub.
Git can help you track and version control your WordPress projects. GitHub has an option to collaborate on projects with other developers.
Keep reading this article to find out more about what Git and GitHub is, and how to use GitHub with WordPress.
What Is Git?
Git is a version control system for developers to track changes of any files they create. Having the ability to record all variations of code makes Git a powerful and helpful tool.
After installing Git on a local server, you can use this system to create a repository inside your project. A Git repository can track all modifications made to your files and show you its history.
With the branching system that Git has, developers can modify their code easily. Create new branches from the master file, and make changes without messing with the source code.
Once they’re done, they can merge the new files back to the master branch.
Git makes fixing issues easier. If there is an error on a project, you can retrieve the previous state of the code with a simple command line.
What is GitHub?
GitHub is a free hosting service for Git to control projects outside the local server. It helps developers to version control their code locally, save it on the cloud, and share it with collaborators.
Since GitHub is a cloud-based system, you can access Git repositories that belong to other developers.
By using GitHub, developers have more opportunities to handle their projects — creating software, managing projects, reviewing code, and so on.
GitHub allows users to collaborate in a team. By utilizing the Git branches system, this tool lets each member work on a specific feature without touching the master code.
It also records who makes a change, when it happens, and what was changed.
To use GitHub, you can access the service by going to the GitHub website or by installing the desktop version on your computer.
GitHub Desktop is one of the most popular Git desktop clients. It provides a Graphical User Interface (GUI) that lets you interact with Git by using a visual interface instead of the command line.
How to Use GitHub for WordPress Development
GitHub makes it easier for you to version control your WordPress tasks. With the branches system of Git, you can modify your WordPress projects and share the changes with other developers through GitHub.
Moreover, you can use it to track updates made on your WordPress website. And see what was changed with the help of some plugins.
Let’s take a look at what tools you can use.
WordPress Git Tools
These following tools can help you develop your WordPress site and keep track of changes made along the way.
If you’re a developer who creates WordPress themes or plugins, using GitHub Desktop to version control your projects can help to simplify your development process.
Before using this program, create a local Git repository for the projects you’re developing. GitHub Desktop will use the information you set on your Git configuration — your email address and username — to associate changes you commit with your GitHub account.
Remember to create a GitHub account before using this application.
To configure GitHub on your computer, you can follow these easy steps:
- Download the GitHub Desktop application.
- Find the file in the Download folder in your computer, and click the file to install the program.
- Launch the program and sign in to your GitHub account.
On the GitHub Desktop client, you’ll see the options to clone a repository from the internet, create a new one, or add an existing repository from your computer.
You can share your project’s local repository to your GitHub account by following these steps:
- Click Add an Existing Repository from your Hard Drive or drag and drop your local Git repository folder to the program.
- Select Publish repository.
- Fill in the Name and Description fields and un-select the Keep this code private option, if you want to share your code publicly.
- Click Publish repository.
- To see your repository on GitHub.com, click the Repository menu and select View on GitHub.
Now you can access every change made on your WordPress plugins or themes. Developers can also collaborate with your GitHub and make improvements to your projects.
VersionPress is an open-source plugin that enables you to version control your WordPress site. By creating a Git repository on your website server, this plugin can track every change in your WordPress files and database.
It is user friendly and shows all your site’s changes by displaying them in a section of the WordPress admin dashboard.
One unique feature of VersionPress is the Undo button that allows you to undo any change on your site. This feature can help you uninstall a theme, cancel a plugin update, remove a recently published post, and more.
However, VersionPress has stricter system requirements than other plugins. For instance, you need to use the latest versions of WordPress, PHP, Git, and so forth. Before using the plugin, make sure your system has met the minimum system requirements of this plugin.
Revisr is a free WordPress version control plugin. Similar to VersionPress, this plugin can create a Git repository inside your website server to track changes.
While VersionPress can commit all changes of your site automatically, Revisr can only track changes that you commit manually. Fortunately, you can commit changes easily from Revisr’s section inside your WordPress admin dashboard.
Easily discard any modification, revert your site’s files or database to the previous version, and backup or restore your website’s data.
To use Revisr, ensure that you have Git and WordPress installed in your web server, and to enable the exec() PHP function. Note, this plugin hasn’t been tested with the three latest versions of WordPress and hasn’t been updated for one year.
Gitium can integrate every change made to your plugins and themes.
For instance, when you modify your WordPress theme locally and commit changes to your Git, Gitium will automatically apply the same to your theme on your WordPress website. Also, if you modify your plugins and themes from WordPress, you can access these modifications through Git.
Gitium is easy to use and setup — just install the plugin, enter your Git URL, and it’s ready to use. However, this plugin hasn’t been updated in nine months.
Precautions When Uploading WordPress Files to GitHub
Before uploading your WordPress plugins or themes to a public repository, it’s crucial to audit your files first.
Make sure your GitHub repository doesn’t include any sensitive information like passwords, website files, database backups, security certificates, etc. Making these files publicly accessible can be an opportunity for attackers to gain access to your website and exploit your data.
Sensitive files can still be included in a GitHub repository. Thus, you need to audit your existing repositories regularly. Using tools like GitRob or truffleHog can help scan through your source code and find potentially sensitive files in your public repository.
If you’re working in a team, ensure you know who has access to specific vital files in your projects and require two-factor authentication to all contributors. Also, remember to remove access from users who no longer contribute to your project.
WordPress Repository on GitHub
As an open-source platform, WordPress allows developers to contribute — fixing bugs, testing new features, writing unit tests, etc.
Since more developers prefer to contribute through GitHub, now they can access WordPress on GitHub and see the mirror of the WordPress development repository.
Users can clone WordPress repositories and work with their codebase. To suggest improvements or fix bugs on the codebase, they can create patches — a particular text file that shows changes to the code. These patches can be submitted to the WordPress Trac.
Usually, contributors on GitHub can send a pull request to submit their suggestions to a repository. However, you will need a Trac ticket to get your patches reviewed in the GitHub pull requests. Also, patches from contributors won’t be merged to WordPress repository on GitHub.
To find more ways to contribute to the WordPress community, you can read the WordPress core contributor handbook.
As a cloud-based system for Git, GitHub can help you track all changes made on your WordPress projects. You can use this service as your tool to share your repository remotely and involve more developers to contribute to your project.
To integrate GitHub to your WordPress projects, you can use these following tools:
- GitHub Desktop — helps developers integrate their local Git repositories to their GitHub account.
- VersionPress — creates a repository on your website server to track all changes in your WordPress website.
- Revisr — tracks every change that you commit manually to this plugin.
- Gitium — enables you to version control your themes and plugins and show them on your WordPress admin dashboard.
Be sure to audit your code before sharing it on GitHub. Since your files are public, be careful not to share any sensitive information in your data.
Access WordPress on GitHub and use their codebase to make improvements on the platform.
Pitch your changes to the core development team by creating patches and sending them to the WordPress Trac.
Now you know what GitHub is and how to use it with WordPress. I hope this article helps you to develop your WordPress projects.