• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How to Integrate WordPress with GitHub

By Abhishek Ghosh September 5, 2022 5:37 pm Updated on September 5, 2022

How to Integrate WordPress with GitHub

Advertisement

The value of content and content marketing is increasing every day. Unlike a decade back, today to operate a serious WordPress website, we should have separate instances of staging, development as well as versioning system to undo the changes quickly.

Traditionally a website running WordPress is somewhat of a single piece of monolithic software. Although WordPress is not totally monolithic. The best would be if we could modernize it to support microservices. At present, that is difficult with a limited budget and limited manpower. In this article, we are discussing:

(i) staging WordPress and
(ii) versioning of WordPress

Advertisement

---

Actually, your local computer is of little use. We need your local computer, main server, GitHub and another server for the whole process. The second server is for live testing. You can shut down that server when not required.

VersionPress adds the flexibility of Git to WordPress. I tested VersionPress latest version Beta (that was built before the era of Pandemic) on abhishekghosh.com and it got activated without any trouble. Staging with VersionPress is described here:

Vim
1
https://versionpress.com/blog/2015/09/versionpress-2-0-staging/

They have explained why the thing is hard. I am not sure why you’ll want so much complexity for a one person authored website.

If you do not use a WordPress plugin for Git management then you need to use a separate WordPress plugin such as WP STAGING for staging. Staging plugins also copy the database. For practical purposes, in this article, I will describe how to push the content from your server towards GitHub from SSH. Please remember that – unless you arrange some methodology for the WordPress MySQL database, this method by itself will not take backup of the database (that is why I informed you about WP STAGING).

 

Steps to Integrate WordPress with GitHub

 

This will help you to keep a copy of the FTP files. Unlike flat backup, you can keep control of what is changed. Log into GitHub and create a repository by following this link:

Vim
1
https://github.com/new

Give a name, add a description and select Private and click Create repository. Now, log in to your server via SSH. If you have installed Apache2 in some method like we have described, then you public root is probably /var/www/html/. Check it by locating wp-config.php file.

You should start working where is the wp-config.php file. Run the following command:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
## take a backup of the server before starting starting
## email and name with your own
git config --global user.email "you@example.com"  
git config --global user.name "Your Name"
## run the main commands
git init
git add .
git checkout -b master
git commit -m "first commit"
## use your own github URL
git remote add origin https://github.com/AbhishekGhosh/example-site.git
git push origin master
## GitHub will prompt for usename and password. Make sure not to commit mistakes.
# If you commit some mistake, then just delete the git setup and freshly start
# rm -rf .git/

It will take some time to copy your all content to GitHub. To clone the Repository to your local computer or another server, run these commands:

Vim
1
2
3
4
5
git init
git add .
## use your own URL
git remote add origin https://github.com/AbhishekGhosh/example-site.git
git pull origin master

You can use Sublime Text Editor for GitHub. There are GitHub packages for Sublime Text Editor and methods exist to easily add GitHub as a remote repository. So you can deploy from localhost (or another server) to GitHub quite easily.

How to Integrate WordPress with GitHub

I do not suggest automatic deployment to the live server. However, below are the optional steps to automatically deploy changes from localhost to live server.

If your
Your example shell username is root
and Server is example.com or IP address
then you
ssh root.example.com

We have described before how to SSH without password.

On your local computer (or a different server), go where is your public root and open a text editor :

Vim
1
nano hooks/post-receive

Add a line of this format:

Vim
1
#!/bin/sh GIT_WORK_TREE=/var/www/html git checkout -f

Make it executable:

Vim
1
2
3
4
5
6
7
chmod +x hooks/post-receive
# git init
git add .
git commit -m ‘commit message’
## myswerver is an example
git remote add myserver ssh://root@example.com/ ~/git/project
git push myserver +master:refs/heads/master

Instead of localhost, you may also auto-deploy from GitHub to a production server. However, I would suggest using manual methods to regularly update from the working live site to GitHub and GitHub to localhost.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How to Integrate WordPress with GitHub

  • OpenShift OctoPress Auto install Script

    OpenShift OctoPress Auto install Script is an Advanced Script to Run OctoPress on Free OpenShift PaaS Practically Without Any Knowing Ruby or Git.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Git with Subversion for WordPress Plugin Development Detailed Guide

    Git with Subversion for WordPress Plugin Development Detailed Guide Explains How To Use Git like GitHub, your Mac and WordPress to Keep Plugins Updated.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy