You'll have to make a direct copy of the production environment to the development environment. Doing a pull on the new development environment isn't going to to retrieve all the files (because git isn't tracking everything).
Copy Magento to the Development Server:
- Zip all Magento files on the production server, then copy them to the development server.
- Clone the production database to the development server
- Extract the files onto the development server
- Modify the
app/etc/local.xml
with the development database details.
- Edit the
core_config
table in the database, changing the base_url
values to the development urls.
- Delete everything in the
var/cache
and var/sessions
folders.
Once you verify Magento is setup and running correctly on the new development server, you can begin to setup Git to push to it. I personally use a bare repository located on the actual server which I push to from my local environment.
Setting up the Development Server:
On your development server, do the following (using an ssh connection)
- Make a directory outside of your Magento directory, and that is not publicly accessible. For example
~/git/development
. Keep in mind that ~
refers to the root directory of the user making the connection.
- Using shell/ssh, navigate to the folder you created to hold the bare git repo:
cd /home/myuser/git/development
- Create the bare repo using:
git init --bare
- Create a post-receive file which will be executed by git when you push to it. This will allow git to automatically apply the changes to your development environment.
vi hooks/post-receive
Paste in the following (change the path to the absolute Magento directory):
#!/bin/sh
GIT_WORK_TREE=/path/to/magento git checkout -f
Save the file. then run the following on the file to set the correct permissions:
chmod +x hooks/post-receive
What the above does is allow you to push to the bare repository, and automatically apply the changes to the Magento files.
Configure your local git instance
Now you want to configure your local git to be able to push to your remote development server.
Add the remote repo:
git remote add development ssh://user@serverdomain.com/~/git/development
Now test pushing your master branch to your development server:
git push development master
You may have to enter a password if you don't have your .ssh key added to the development server.
If done correctly, you can now simply push changes to your development environment, and the site will be updated pretty much instantly after doing so.