How do you configure Expression Engine to run with the most powerful version control architecture Git.
I have had experience using both EE 1.6 and EE 2 with git. EE 1.6 was a real headache mainly because of template synchronization. Let me give you a walk-through to using Git and EE2 on Eleven2 servers.
What we are doing is a fully version controlled and command line deployment of EE2.
Add/Edit Files Locally -> Push to Remote Server -> Deploy
Before we begin, lets make the following assumptions.
- You have installed git on your local system
- You have a git enabled remote server
The first we do is set up EE2 in our local system and git it. We need to create a .gitignore file as we have to exclude config.php and few other folders from being copied over to production.
My .gitignore file looks like
// File .gitignore : Make sure its in the project directory .DS_Store system/cache/* system/config.php system/config.local.php images/uploads images/avatars/uploads images/member_photos/ images/captchas/* images/*.psd images/contestphotos images/forum_attachments images/country
cd /wamp/htdocs/ee2 touch .gitignore // Next copy and paste the content into .gitignore
Now we are ready for initializing git
cd /wamp/htdocs/ee2 git init git add . git commit -a -m "Initial Commit"
This will gitify your EE2 installation.
Next you need to set a remote repository in your remote server. This remote repo can either be on your own server or github.com. Its always advisable to set up the remote repo on
// SSH to Remote server : Username : app ssh -p 1122 firstname.lastname@example.org cd /home/app/git git init --bare
This will create a bare remote repository in the server.
In your local repo, we need to add the remote server. So navigate to your local directory
cd /wamp/htdocs/ee2 git remote add origin ssh://email@example.com:1122/home/app/git git push // This will push all the files from local to remote
So all our local changes are now migrated to remote repository. And now we need to pull all those files and deploy it in remote server public_html
ssh -p 1122 firstname.lastname@example.org cd public_html/ git clone /home/app/git
This will create a full fledged repository in the publc_html and will get all the files from the remote repo /home/app/git.
Final Step: Deployment
What i do to deploy is
// Local git commit -a -m "Commit message here" git push origin master ssh -p 1122 email@example.com "cd public_html;git pull origin master"
Thats it easy peasy. I dont have to upload any files using ftp. Just 3 lines and my site is synced.