• 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.

This Article Has Been Shared 269 Times!

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

Actually a list should normally appear here. Automated calculation failed.

Additionally, 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

  • What is Configuration Management February 5, 2023
  • What is ChatGPT? February 3, 2023
  • Zebronics Pixaplay 16 : Entry Level Movie Projector Review February 2, 2023
  • What is Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023

About This Article

Cite this article as: Abhishek Ghosh, "How to Integrate WordPress with GitHub," in The Customize Windows, September 5, 2022, February 6, 2023, https://thecustomizewindows.com/2022/09/how-to-integrate-wordpress-with-github/.

Source:The Customize Windows, JiMA.in

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT