How to Integrate and Use + Helpful Tips


GitHub is an essential tool for web developers. By storing your project database on its cloud-based remote server, different users can track, manage, and change it anytime.

Integrating WordPress with GitHub can improve your website development process and make your team’s workflow more efficient.

This article will cover all about WordPress and GitHub integration. We will explain why you should use GitHub and provide step-by-step instructions to integrate it with WordPress. Finally, we will recommend WordPress GitHub plugins to help your development tasks.

Why Should You Choose GitHub for WordPress Development?

Before discussing GitHub, we will explain what Git and version control are. They are essential for understanding GitHub and how it can improve your website development workflow.

What Are Version Control and Git?

Version control is a system for tracking changes in a set of files, such as software development codes. It stores all versions of your project files in a repository or repo for short.

There are two main types of version control systems – centralized and distributed.

Centralized version control systems require users to connect to the main repository to make changes. When the repository encounters a problem, users can’t access or modify it.

Meanwhile, distributed version control systems allow users to make modifications without accessing the main repository. Users can clone the repository and modify files on their local machine.

Git (Global information tracker) is the most popular distributed version control system. Since Git is hosted on a remote server, multiple people can access and work on the same project simultaneously.

There are various Git hosting platforms, but GitHub is the most popular. It also offers additional features on top of the essential Git functionality.

When developing a WordPress site, you may need to edit plugins, themes, or core files. Although you can edit WordPress files with only text editors, it is a tedious process that’s prone to errors.

GitHub creates a version control that backs up your WordPress files. It also shortens the development process, allowing you to immediately apply changes to the server.

Important! WordPress doesn’t recommend modifying your core WordPress files except for wp-config.php. You should only modify a core file when it’s faulty and not without creating a backup first.

What Are the Benefits of GitHub?

GitHub has many benefits for web developers, including:

  • Version control. This platform stores different versions of your project and tracks every change. You can identify each change and revert to a previous version when needed.
  • Free web hosting. GitHub offers hosting services for WordPress websites. This way, you can apply changes to the website directly on GitHub, increasing efficiency.
  • Integration with WordPress. WordPress has various GitHub plugins with features that can help your development projects.
  • WordPress plugin and theme repositories. Many developers use GitHub repositories to store their themes or plugins. If a plugin or theme is unavailable in WordPress’s official library, you can likely install it from GitHub’s repository.
  • User-friendliness. The GitHub desktop application has a user-friendly visual interface, making it easier to use than the typical command-line Git. And since it has comprehensive documentation, it is an excellent option for Git beginners.

How GitHub Benefits Distributed Teams

The main benefit of using GitHub is easy collaboration, thanks to features such as:

  • Cloud-based repository. GitHub lets users clone the main repository on their local machine. This way, developers can make changes to the repo offline and merge them with the version on the cloud when finished.
  • Branching. Git branches simplify task distribution. They let team members work on independent development lines simultaneously without clashing with each other.
  • Pull request. This feature lets you assign up to 10 people to work on a specific task. This way, you can know what others are working on and review the changes before applying them to the main repository.

How to Create a Local WordPress Environment for Git

Before using GitHub, create a local version of your WordPress site. This local development site is for testing changes, including new themes, plugins, or designs.

Any modifications on your local WordPress site will not affect the live website until you deploy them.

Local WordPress Tools

Use a local web development tool to create a WordPress environment on your machine. Based on the functions, there are two tool types – general-purpose and WordPress development tools.

General-purpose tools let you create any web development environment. They support all Content Management Systems (CMS), but you must install the CMS manually.

Although you can use general-purpose tools for WordPress development, we recommend WordPress-specific development ones instead. They are pre-installed with WordPress, making them more convenient.

For this tutorial, we will use Local WP. This development tool has a Graphical User Interface (GUI), making it user-friendly and ideal for beginner web developers. Follow these steps to set up Local:

  1. Visit Local’s release note web page.
  2. Download Local’s latest version for your operating system.
Local's latest version download page
  1. Run the Local installer. Follow the installation guide according to your operating system.

After the Local WordPress installation process finishes, create a local development site:

  1. Open Local. For now, skip the account creation step by clicking the X button.
Local's welcome screen
  1. On the Terms of Service window, check the box and click I agree.
  2. On Local’s dashboard, click Create a new site.
Creating a new site on Local's dashboard
  1. Select Create a new site and click Continue to proceed.
Local's create a site window
  1. Enter your website name and click Continue.
Naming your new website on Local
  1. Select your local environment settings. If you are unsure, select Preferred. Click Continue.
Setting your new website's environment on Local
  1. Enter your WordPress account details. For WordPress multisite, select Yes under Advanced options. Click Add Site to confirm, and your new site will appear on the Local dashboard.
Setting up your WordPress account on Local

Once your local environment is ready, install a text editor to change your site data. With Local, you can install VSCode directly from its dashboard:

  1. From the Local dashboard, open the add-ons menu represented by the puzzle icon on the left sidebar.
Local's add-on installation menu
  1. Click Xdebug + VS Code.
Xdebug + VS Code plugin on Local's add-on menu
  1. The installation window will show. Click Install Add-on.
Installing Xdebug + VS Code Local add-on
  1. Wait until Local finishes installing and restarting.

How to Install Git Locally

You must install local Git first to use the GitHub remote repo. Your local Git repository is where you will commit changes before pushing them onto GitHub.

A machine running the latest Linux or macOS may have Git pre-installed. Check by typing git –version in the Terminal.

For Windows, type git version into the Command Prompt.

If Git is already installed, your command-line application will return Git’s version number. Otherwise, it will tell you that Git is an unknown command or ask whether you want to install it.

You can manually download the Git installer and run it on macOS, Linux, or Windows. Alternatively, download one of the Git GUI clients if you prefer working with a user-friendly interface instead of the command line.

Git installation steps differ depending on your operating system. This tutorial will show you how to install Git on the Windows command line interface:

  1. Download the Git installer for Windows.
  2. Run the installer. Click Next and Finish to complete the installation using the default option.
  3. Open the Windows Start menu and search Git Bash. Press Enter.
  4. Verify if Git is already installed by executing the git version command.
Git version command returning installed Git's version number

Now, create a local repository using Git Bash. If you are unfamiliar with Git, read our basic Git commands article to learn its basics.

For example, here is how to create a repository for WordPress’ Twenty Twenty default theme:

  1. Explore the wp-content directory and open the twentytwenty theme folder.
  2. Right-click anywhere on the folder and click Git Bash Here.
Git Bash Here on a repository folder
  1. A Git Bash window will open. Type git init and hit Enter.
Using the git init command
  1. Type git add . and press Enter.
Using the git add. command to add changes
  1. Type git commit -m “message” and hit Enter. Replace the message with any phrase, but make sure it is clear and descriptive.
Using the git commit command to save the changes to the repository

If successful, a hidden .git folder should show up.

A hidden .git folder appears after creating a remote repository

How to Create and Commit to Your First GitHub Repository

Now, you will learn how to create a repository on GitHub and push the local one there. The GitHub repository is where all the team members will work on applying their changes.

How to Register for a GitHub Account

If you already have a GitHub account, skip this section and sign in to your account. Otherwise, do the following:

  1. On your web browser, go to GitHub and click the Sign up button on the top right of the page.
The Sign in button on GitHub's website homepage
  1. Enter your email address and click Continue to proceed.
  2. Create a username and password. Then, choose whether you want to receive news and updates. Click Continue.
GitHub's account registration page
  1. Verify your account by clicking Start Puzzle and solving it. Then, select the Create Account button.
  2. Check your email inbox for a launch code from GitHub. Type the code into the Enter code boxes and hit Enter.
  3. Answer some questions to automatically configure the GitHub account based on your preferences. Otherwise, click Skip personalization.
GitHub asks questions for a new account personalization
  1. Choose either the Free Account or Team Account.
  2. Wait until GitHub redirects you to your account page.

How to Create Your First GitHub Repository

To create a new repository, sign in to your GitHub account. Then, on any page:

  1. Click the + icon on the top right of the page. From the drop-down menu, select New repository.
The New repository button on GitHub
  1. On the Create a new repository page, select an Owner and enter your Repository name. Optionally, add a Description for your repository.
  2. Select your repository’s visibility. Refer to GitHub’s guide on repositories for more information.
The Create a new repository page on GitHub
  1. Since we are pushing the local repository, skip Initialize this repository with: and click Create repository. Once created, GitHub will show your new empty repository.
The Create repository button on GitHub's new repo creation page

How to Make Your First GitHub Commit

After creating a GitHub repository, make your first commit by uploading your local repository data:

  1. Open your GitHub repository.
  2. Under the Quick setup section, find and copy the repository’s URL.
The new repository's URL shows under the Quick Setup section
  1. Open Git Bash. Type git remote add origin URL and press Enter. Don’t forget to replace URL with your repository’s link.
Connecting a remote repository to the local one using git remote add origin
  1. Type git push -u origin master and hit Enter.
Pushing local repository's file to remote using the git push -u origin master command
  1. The connect to GitHub window will appear. Select Sign in with your browser.
Sign in with your browser option in the Connect to GitHub window.
  1. Sign in by entering your GitHub username and password.
  2. In the authentication screen, select Authorize GitCredentialManager.
The GitHub authentication screen
  1. Open your GitHub repository, and your local repository’s file should appear.

After you make changes to your local repository, push it to GitHub. It will update your GitHub repository with the new changes from the local version.

How to Fetch Updates From GitHub to Your Local Computer

After pushing your local repository’s files to GitHub, other users can make changes to them. To apply these changes to your local repository, you must fetch the updates from GitHub.

Fetching means downloading and merging updates into your local repository. While pull also downloads the updated repo, it doesn’t automatically merge the data with your working files.

The steps for fetching updates from GitHub are:

  1. Open your project folder. In this example, we will open the Twenty Twenty WordPress theme folder.
  2. Right-click anywhere and select Git Bash Here.
Git Bash Here on a local repository folder
  1. Type git fetch URL and press Enter. Your local repository should now be updated.
Downloading and merging GitHub repository with local using the Git Fetch command

How to Use GitHub for WordPress Development

After preparing all the tools, you can start using GitHub to work on your site development. Here is a sample workflow for changing your site’s theme:

  1. Fetch your website theme’s GitHub repository.
  2. Make changes to the theme and test it on the local server.
  3. Open the theme’s folderright-click anywhere → select Git Bash Here.
  4. Type git add and press Enter. This tells Git that you want to include the changes for the next commit.
  5. Apply the changes to the local repo by executing the git commit command.
  6. Push your updated local repo to GitHub with the git push -u origin master command. Replace master with the branch name when pushing changes to another branch.
  7. Once ready, apply the changes to the live site by deploying your remote repo.

There are many ways of deploying remote repositories to the live production server. The most convenient method is to use a WordPress GitHub plugin, like WP Pusher.

Here is how to use WP Pusher to deploy your GitHub repo to the live website:

  1. Download and install the WP Pusher plugin.
  2. On your WordPress sidebar, navigate to WP Pusher.
WP Pusher plugin menu on WordPress' sidebar
  1. Navigate to the GitHub tab and click Obtain a GitHub Token.
A button on WP Pusher for obtaining a GitHub token
  1. An authentication pop-up window will appear. Authorize WP Pusher to access your GitHub account.
  2. Copy the token from the pop-up window and paste it into WordPress.
  3. Click the Save GitHub token button to confirm.
Save GitHub token to authorize WP Pusher's access of your GitHub account
  1. Navigate to the WordPress sidebar WP Pusher Install theme or Install plugin. In this example, we will Install a theme.
  2. Fill in the Theme repository field with your GitHub repository’s name.
  3. For the Repository branch field, enter main.
  4. Click the Install theme button.
Installing theme menu on WP Pusher plugin
  1. After the installation, navigate to AppearanceThemes → and Activate your newly deployed theme.

Whenever you push changes to repositories, go to WP Pusher Plugins or ThemesUpdate. Otherwise, your changes will not show up on the live site.

Aside from improving development workflows, integrating WordPress with GitHub has other purposes. For example, you can install plugins or themes from GitHub and host your website on this platform.

How to Install WordPress Plugins and Themes From GitHub

WordPress developers typically have GitHub repositories for their themes or plugins. If these themes or plugins are unavailable in the WordPress official library, you can install them from GitHub.

The steps to install a theme and a plugin are similar. Here’s how to download and install a WordPress plugin from GitHub:

  1. Open GitHub and look for the plugin you want to install.
  2. On the plugin’s GitHub repository page, click Code Download ZIP.
The Download ZIP button on a plugin's GitHub repository page
  1. Select your desired directory and click Save.
  2. After it finishes downloading, install the WordPress plugin manually.

GitHub Pages for Static WordPress Hosting

GitHub offers a free hosting service called GitHub Pages. It lets you create a static site directly from your GitHub remote repo.

However, it will convert your WordPress website into static, omitting dynamic functionalities. A static site is ideal for a simple portfolio, blog, or project demonstration page.

Also, websites hosted on GitHub Pages will use a github.io domain by default. To change it, purchase a domain from a registrar like Hostinger.

To host your WordPress website on GitHub Pages, follow these steps.

1. Create a New GitHub Pages Repository

A GitHub Pages repository is where you store your static site’s data. Creating one is the same as creating a new GitHub repository. However, in this case, the repository’s name will be username.github.io.

After creating a remote GitHub Pages repository, clone it to your local machine:

  1. Open GitHub and navigate to the repository’s page.
  2. Click Code and copy the repository’s URL.
Copying a GitHub repository's URL.
  1. Navigate to the folder where you want to save the repository.
  2. Right-click anywhere and select Git Bash Here.
  3. Type git clone URL and hit Enter. A new folder with your GitHub Page repository’s name should show up.
Cloning a GitHub repository to your local machine

2. Create a WordPress Site

The WordPress site will be your development environment. It’s where you will make changes to the live website’s content and design hosted on GitHub pages.

Using tools like Local, you can host your WordPress GitHub Pages sites on a local server. Otherwise, use web hosting services to allow other WordPress users to access it remotely.

When hosting your development site remotely, set it to private to prevent users from visiting while it’s still in the works.

Check our WordPress tutorial to learn more about installing and using the CMS. Once your site is created, configure its content and design.

3. Convert the WordPress Site to Static HTML

GitHub Pages only supports static pages. Since WordPress sites are dynamic, convert them to static before deploying.

There are different methods to convert your WordPress site, but using a plugin is the most common. In this tutorial, we will use the freemium plugin Simply Static.

To convert a WordPress site using Simply Static, set up the plugin first:

  1. Download and install the Simply Static plugin.
  2. Navigate to the WordPress dashboard sidebarSimply Static Settings General tab.
Simply Static plugin's setting menu on WordPress
  1. Under Destination URLs, select Use absolute URLs.
  2. Enter your GitHub Pages’ site URL. For sites with the free github.io domain, the URL is username.github.io.
  3. For the Delivery Method, select Local Directory.
  4. Enter the local path to your GitHub Pages repository clone. This is where Simply Static will save your site’s HTML files.
  5. Click Save Changes.
Setting up Simply Static site URL, and delivery method and destination

After the configuration completes, it is time to convert your WordPress site:

  1. Navigate to your WordPress dashboard’s sidebarSimply Static Generate.
  2. Click the Generate Static Files button. Wait until the export process completes.
Generate static HTML files on Simply Static
  1. Open your local GitHub Pages repository. If the export succeeded, the HTML files should show up.

4. Deploy the Site to GitHub Pages

Deploy your static WordPress site to GitHub Pages to make your site live. Unlike other hosting services, pushing to the GitHub Pages repo will automatically deploy changes to the live site.

To deploy your site, push the HTML files to your GitHub repo:

  1. Copy your GitHub Pages repo’s URL.
  2. Open your local repository folder.
  3. Right-click anywhere and select Git Bash Here.
  4. Enter git remote add origin URL and hit Enter. If the error: remote origin already exists message shows up, you have already added the remote repository. In this case, proceed to the next step.
  5. Push all the files to the GitHub repository by typing git push origin -u master and press Enter.
  6. If GitHub asks you to sign in, select Sign in with your browser and enter your username and password.

After pushing the HTML files to your GitHub Pages repository, you can now access the live site.

Whenever you make changes to your site, create new HTML files and push them to the GitHub Pages repository. If you are using the GitHub desktop client, click Push Origin.

If you prefer automatically deploying your site’s HTML files to GitHub Pages, consider purchasing Simply Static’s pro version. It starts at $99.99.

Using plugins can further optimize your workflow, making WordPress development more efficient. Here are our picks for the three best GitHub WordPress plugins, each with different purposes:

/cta

1. WP Pusher

WP Pusher plugin's website homepage

WP Pusher helps deploy a new theme or plugin to your live WordPress site using the repository’s URL. It lets you install a theme and plugin directly from the WordPress dashboard.

WP Pusher ensures a more effective workflow for users who frequently update their plugins or themes. It is also useful for installing plugins or themes unavailable in the WordPress library.

To install a WordPress theme using WP Pusher, simply enter its repo link and click the Install button. The plugin also has Themes and Plugins sections that list all installed plugins and themes.

WP Pusher is available in free and premium versions. The premium plan offers more features, starting at $99/year. It also comes with a 30-day money-back guarantee.

Key Features:

  • Multi-platform support. WP Pusher integrates with multiple Git-based repo services, including GitHub, GitLab, and Bitbucket.
  • Push-to-deploy. Automatically updates WordPress themes or plugins every time users push to Git.
  • Multisite support. This plugin will work for all websites within a WordPress multisite network.

2. Git Updater

The Git Updater logo

Git Updater is a simple plugin for automating updates to GitHub-hosted WordPress themes, plugins, and language packs.

Git Updater must have authorized access to the repositories to work properly. Additionally, it requires themes and plugins’ style.css files to include specific lines of code.

The plugin can periodically check for newer updates on your theme and plugin repositories. If it detects a newer version, it will automatically deploy the changes on the live server.

Git Updater offers free and pro versions. The pro versions start at $30/year and come with additional features, such as remote installations and branch switching.

Key features:

  • Automatic updates. Automatically updates a theme, plugin, or language pack as a new version appears on the GitHub repository.
  • Remote plugin and theme installation. Lets you install GitHub-based themes and plugins via the WordPress dashboard.
  • Private and public repository support. Track updates from public and private repositories.
  • Branch switching. Users can choose whether Git Updater looks to the master branch or other development branches.

3. GitHub Embed

GitHub Embed's plugin banner

GitHub Embed is an open-source plugin for embedding GitHub information into your website. It currently supports:

  • Repositories
  • User profiles
  • Project milestones summary
  • Project contributors

To embed GitHub information, simply paste the repo URL on your site. This plugin automatically fetches and applies any updates made to the embedded information.

GitHub Embed is especially useful for project websites. With this plugin, developers can keep information about their projects on the website up to date.

Best of all, this plugin and all its features are completely free.

Key features:

  • Styling customization. The plugin has styling classes, allowing users to customize their embedded information to match their website design.
  • Automatic information updates. GitHub Embed automatically updates embedded information every time a user makes a change on GitHub.
  • Multi-information embedding. Users can embed multiple pieces of information on their sites.
  • Milestone summaries. Provide details about your project’s progress, including the issues, due dates, and milestone descriptions.

Conclusion

GitHub is a Git hosting service that allows developers to collaborate on projects more efficiently. The platform has version control, tracking, and branching features, enabling simultaneous and organized development of the same project.

Integrating WordPress with GitHub will improve your website development workflows. This article has explored each step to integrate GitHub with WordPress.

GitHub integration lets users install WordPress plugins from their repositories and host a WordPress site on GitHub Pages. Additionally, plugins like WP Pusher, Git Updater, and GitHub Embed can automate some integration processes.

We hope this article has helped you understand how to use GitHub to support your WordPress projects. If you have any questions, don’t hesitate to leave us a comment.

Author

Aris is a Digital Content Writer at Hostinger who is passionate about IT and WordPress. Through his writings, he wants to share his knowledge and inspire people to start their online journey. In his free time, Aris loves watching gadget reviews and scribbling random doodles.



Source link

Home
We will be happy to hear your thoughts

Leave a reply

Best & Lowest Rates of all online shopping Products
Logo
Compare items
  • Total (0)
Compare
0
Shopping cart