How to setup GitHub with Wordpress - wordpress

I'm trying to setup a workflow that works for me. Developing wordpress sites
Basically I use dropbox to work on my local development...That way it's all backed up if computer crash or stolen. (So far working good)
I got Github account, created a Master REPO. And downloaded the GitBox software to push to this Master Repo (Worked Good so far)
Two questions I have:
How do I set it up so my wordpress database on local can be send to github and then when I push it to live server, it only updates the changes in the database?
How do I setup the ability to push my Github Master Repo to Live Server? I'm using AWS EC2 Instance.
So my work flow is
Local (development) > GitHub (Master Repo)
GitHub (Master Repo) > Live Server Production
If there is a better flow, I'm open to implement it.

Git (http://git-scm.com/) is only made for data. You can't commit databases. But you could create a mysqldump? Like this: Synchronizing a MySQL Database with Git and Git Hooks

Related

How to work in parallel with another dev on Wordpress-based website on local machine

I'm working on WP-based project which is installed on my local machine (Wamp), so the latest version of the database and WP files is on my laptop.
I'm pushing WP files into git repository, so another dev can pull the files from there and push his code into the git as well. Merging of WP files works fine with git, the problem is the database changes. Once another dev changed something is his local database, I had to do the same in my DB to keep my database up to date, which didn't really work for us.
We are trying to use a centralized database on an external server: all the files are stored on our local machines and we connect to the external mysql server using different DB users. It works better in terms of merging of DB changes, since we both change the same database, but we're having troubles if one of us need to install a plugin, as in this case the dev who install the plugin physically have the plugin files on his local machine, but another dev - doesn't have it. As a result we have to add plugin files manually and then one of us just activate the plugin. Another downside of such approach is - we both connect to the external database, so we are loosing time based on a ping to the server each time we need to re-load a webpage during development in comparison to the same action using a local database.
Please describe how do you work on Wordpress-based website in parallel with another devs? Which tools are you using to make development process smooth and to avoid issues I described above?
Thanks.

How can I push a repository to my computer and my online server?

I have figured out how to create a repository on github. Now I am trying to push the repository to both my macbook pro and my server, which is hosted through http://namecheap.com, and be able to understand how to keep things simple. I am using wordpress on my server and I have a template theme. I want to edit my files on my mac and then push them to the website, keeping everything easy.
There is plenty of information out there on how to get started with github, so I will just focus on clearing up a misconception:
Now I am trying to push the repository to both my macbook pro and my server
You do not push from github to a server. You need to clone your github repo to your development (macbook) and production (server) environments.
git clone https://github.com/USERNAME/REPOSITORY.git
https://help.github.com/articles/fetching-a-remote/
Alternatively, you can push existing code to an empty repository by initializing locally, setting your remote and then pushing
git init
git add -A
git commit -m "Initial commit"
git remote add origin https://github.com/USERNAME/REPOSITORY.git
git push origin master
Once you have your repo setup, your typical workflow will look something like this:
Make changes in your development environment (macbook).
push those changes to github.
pull those changes from github in your production or staging environment (server).
One of the main things you need to use git this way is access to a terminal on the hosting serve, to push your files directly through git that should be installed as well.
Alternatively you can upload file using any available protocol such as (s)FTP or SSH direct to your server. In this case you'll be using git to version and manager your templates but not to upload or release them.
I've seen that cheapnames.com provides Softaculous as a mechanism to manage their servers. This software also provides synch and install scripts.

Version control: merging changes between dev and live sites

I am new to version control such as git so this may be an easy answer for some... for all my searching I can't find a simple enough answer.
I am developing a wordpress site on a dev server. Another developer is making changes to the live (production) site and some changes are also ftp'ed to the dev site.
Is there a way for me to merge those changes to my local copy so I don't override his changes and he doesn't override mine?
I would hate to push a file to the live site that doesn't have his changes and screw the live site up...
You need to do a git pull before trying to push your changes to the remote.
It's always a good practice to get hold of the latest master branch (assuming that's used on your dev server) before you
start working on your feature branch
push your code
Ideally, before you start working on a feature, get your feature branch to branch off from the latest master. You can do a git fetch <remote_name> and then do this -
git checkout -b <feature_branch> <remote_name>/master
Or better yet, merge the remote master in your local master and then create the feature branch from your local master.
This will ensure that your is created off the latest master on your dev server.
When you cannot push to the dev server, you can do a git pull which will fetch and merge the latest master, to ensure that any of your co-workers' work is included in your work. After you do that, you will not have any issues pushing your code.

Manage wordpress blog on remote server via git

I want to be able to develop my plugins & themes on my machine and the changes be reflected on my server almost instantly. Also I want a backup plan. So git & github seems a very good solution. I want to make regular changes to the server (push from local) and once in a while upload them on github too (local to github or remote to github).
The question is can I clone the repo from github to my remote server and to my local machine and be able to push from local to remote or pull from github to remote (if I'm not at home)?
Edit: I did a research and I found out that I actually need a bare repo in the server, but i want it to be able to push/pull to/from github.
In github and bitbucket (https://bitbucket.org) you can add any number of ssh keys from different machines and push and pull from anywhere you want. The command to generate such a key is
ssh-keygen
answer the questions with enter and the ssh key will be in /home/user/.ssh/id_rsa.pub. You have to do this for every machine you want to push and when the repository is set to private, yo also have to do it for those machines, you want to pull from.
So the workflow would be
editing locally
pushing to github/butbucket repo: git push -u origin
log in to the machine where wordpress is running: git pull

How do I download my Appfog app's live file system?

Hello I am a Appfog beginner and I want to ask if I upload picture/plugins/themes via the wordpress admin. Because appfog does not currently support a persistent file system, all the plugins/pictes/themes not in the source code will be lost. Is there anyway to backup the current live system and include these files in the source code that I upload? The download source code button or the "af pull" command will only download the last source code I uploaded not changes that where made for example when I install a plugin.
You can add a helper php script to your app like this:
https://gist.github.com/4134750
You can manually download single files using af files <appname> /app/<filename> but this would be painfull for your purposes.
You would be much better served by setting up your Wordpress installation to run locally using Mamp or Xampp. Pull your app as it is from AppFog, host it locally using Mamp, making your file system changes, then pushing those changes to AppFog.
Here are a few reasons why making changes locally then updating AppFog apps is better:
If your running multiple instances of your wordpress app, only one of them will get the installed plugin. Installing the plugin locally and pushing insures all instances get the plugin.
Its much faster to develop and test locally and you can see the results of your changes before impacting your live site.
Your live production site will not go down if your plugin install fails or somehow makes an unintended change. This is also true for Wordpress updates, do them local then push to production.
If your have the changes on your local box you can use version control to track and tag releases before updating production.
blue-green deployments become trivial. Have two production apps, a primary and a slave app. Update your code locally then update the slave and test it then promote it to primary by mapping the domain to it. Then you demote the previous primary to slave by unmapping the domain. The slave is always one update older and you can switch back two it if you discover issue with your primary.
Curating your Wordpress apps this way will allow you to take advantage of power the AppFog platform provides.
I found this script "zipit" even better than the "ls" script Sea Comet provided. This will zip up the entire live app directory and then you download it. This way, you can make changes via the wordpress admin, get it all working the way you want it, then use zipit, unzip the file and push it to your app on appfog and the state is totally saved across restarts.
https://github.com/zeroecco/zipit/blob/master/zipit.php
You can find more info in this blog post over on the old PhpFog blog:
http://blog.phpfog.com/2012/11/16/how-to-download-your-entire-application-not-just-code-from-php-fog/

Resources