Git deploy

Creating Git repository


Connect SSH


Create .git directory outside public_html and create bare repo

mkdir project.git
cd project.git
git --bare init

Create post-receive hook

cd hooks
nano post-receive
chmod +x post-receive

post-receive contents

git --work-tree=/home/username/public_html --git-dir=/home/username/project.git checkout -f


Create repository

cd project
git init

Add remote to local repository

git remote add staging ssh://

Just commit and push

git commit -am "first edit"
git push staging master

Default push to staging

git push --set-upstream staging master

Reset remote

To reset remote and push files again to remote

git --work-tree=/home/username/public_html --git-dir=/home/username/project.git reset --hard


Useful resources


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s