First, install git server in the machines. Then, install git client in local machine. After creating the remote and local repositories, the trick now is creating a hook in the remote servers to update the code change at the shell. Git hooks are scripts that are executed when specific actions are performed to our repository. In our case, we’ll want the post-receive
hook to be executed when we push changes from our local repository.
Remote Server
$ mkdir -p /home/git/project_name.staging.git
$ cd /home/git/project_name.staging.git
$ git init --bare
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/project_name git checkout -f
$ chmod +x hooks/post-receive
Local Server
$ cd /var/www/project_name
$ git remote add production ssh://staging.website.com/home/git/project_name.staging.git
$ git push staging +staging:refs/heads/staging
Posted by kiatng to Git (2014-06-21 06:07)