The Local Repository must Exactly Know his Origin and this is possible in two Ways:
- If your Local is a Clone of the Remote one
The Cloning Procedure is like:
git clone ssh://<userName>@<remoteServer>:2222/path/To/Your/remoteRepo.git localRepo
- Your Origin has been set on the .git/config local file
One way to Set the Origin by a Command is:
git remote add origin ssh://<userName>@<remoteServer>:2222/path/To/Your/remoteRepo.git
- If your Local is a Clone of the Remote one
- Next you need Make a hooks/post-receive file inside of the Remote Repo.
You can follow this Procedure:
ssh -p <serverPort> <userName>@<serverName>
cd path/To/Your/remoteRepo.git
touch hooks/post-receive
chmod +x hooks/post-receive
pico hooks/post-receive
Insert in the post-receive file a Content like this below:
#!/bin/bash #CONFIG LIVE="/path/To/Your/liveRepo" read oldrev newrev refname if [ $refname = "refs/heads/master" ]; then echo "************* DEPLOYING TO LIVE SITE ******************" unset GIT_DIR cd $LIVE git pull origin master echo "********************* DONE ****************************" fi
(It's Essential to Leave a White Space between brackets "[]" and "$refname")
Save and exit with:
Ctrl+x
Now your Remote Repository is Set to Automated Deployment of Changes on Live for every Local:
git push origin master
Every Change you Push on your Remote Repo will be Now Automatically Reflected on Live.
Check this...
Bloogger Blogger, Google Blogger, Google Google
Apache Virtual Host
Monday, October 31, 2011
Git Local Repository Automated Deployment on Live of Changes to the Remote Web Server
You dispose of a Git Repository on your Web Server and you want an Automatic Deployment on Live of Changes after a Local Push to Origin.