git hook (post receive)

I have app on my virtual server: app. Also i have git repository on the same VPS.

Simple way to init git repository:

mkdir app.git && cd app.git

git init –bare

nano hooks/post-receive

paste code, for example, pull app from local repository:


git –work-tree=/home/user/app/ –git-dir=/home/user/app/.git pull origin master

After that make file executable:

sudo chmod +x hooks/post-receive

If you are misunderstand  how to clone repository you created on server, it can help(setting from local repository – path to remote origin):

url = ssh://my_user@my_ip:ssh_port/home/my_user/app.git

for example if your ip is, and ssh port is 22(default) url must be:

url = ssh://my_user@


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