#Setup Remote Server
- (taken from http://mikeeverhart.net/git/using-git-to-deploy-code/)
- `mkdir -p /home/cube/gitrepos/displaay.site.git`
- `cd /home/cube/gitrepos/displaay.site.git`
- `git init --bare` - Create a bare (empty) git repository inside of your new directory
- Create a post-receive “hook”. This hook gets executed automatically each time you push code changes to the server. In our case, we’ll use the hook to checkout the latest code from our repository:
- `nano hooks/post-receive` the paste in:
```
#!/bin/sh
GIT_WORK_TREE=/home/cube/clients/displaay.com git checkout -f
```
- You can add other shell code to the post-receive hook to do things like chmod files and directories, call other scripts, etc. each time you push updated code to the server.
- `chmod +x hooks/post-receive` - Make your post-receive hook executable
- `mkdir ~/clients/displaay.com`
#Setup local Repository
- (Partially taken from - http://davidwinter.me/articles/2012/04/09/install-and-manage-wordpress-with-git/)
- Create folder in LocalSites `mkdir newsite.com`
- `git init`
- Create Readme file `README.md`
- Initial Commit `git commit -m "Initial commit."`
- Add submodule `git submodule add git://github.com/WordPress/WordPress.git wordpress`
- Checkout latest version `cd wordpress`, `git checkout 3.9.1`
- Add to SourceTree
- Add files & Commit `cd ..`, `git commit -am "Checkout WP 3.9.1`
- Copy Across files to be customised:
```
cp -R wordpress/wp-content ./wp-content
cp wordpress/wp-config-sample.php wp-config.php
cp wordpress/index.php .
```
- Add files & Commit
- Change /index.php
```
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
changes to
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
```
#Add Remote to dev server
- `cd /LocalSites/project_name`
- Add a remote source that references the server and repository we setup in the previous steps:
```
git remote add production ssh://cube@b2-3b-syd.hosting-services.net.au:2683/home/cube/gitrepos/displaay.site.git
```
- Do an initial push to the remote server, which will setup the master branch. If your branch is named something other than master then use its name in place of master in the following command:
```
git push production +master:refs/heads/master
```
- Also, add the wordpress (or submodule) repo to remote as above, then push the tag after checking it out locally `git push production 3.9.1`