Find us on facebook

Jan 31, 2018

On git push , publish files to live

git init --bare
cd project.git
cd hooks

cat > post-receive

#!/bin/sh
git --work-tree=/var/www/html/project --git-dir=/home/ishara/git/project.git checkout -f

CTRL+D to exit

chmod +x post-receive
 

When deploying files, you need to give permission to /var/www/html/project 
add system user group permission to /var/www/html/project using following command.

chown -R user:group projectfolder
 

In local git repo add remote
 
local .git/config
[remote "live"]
        url = ssh://ishara@111.111.11.11/home/ishara/git/project.git
        fetch = +refs/heads/*:refs/remotes/live/*
[remote "repo"]
        url = git@222.222.22.222:project.git
        fetch = +refs/heads/*:refs/remotes/repo/*

 
push command from local machine
git push live master (deploy live)
git push repo master (deploy to git server repo)
 

No comments:

Post a Comment