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.
-
The Local Repository must Exactly Know his Origin and this is potential in two Ways:
-
If your Local is a Clone of the Remote one
The Cloning Procedure is like:git clone ssh://USERNAME@
: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@
:2222/path/To/Your/remoteRepo.git
-
-
Next you need Make a hooks/post-receive file inside of the Remote Repo.
You can follow this Procedure:ssh -p
USERNAME@ 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
/nif [ $refname = "refs/heads/master" ]; then
/necho "************* DEPLOYING TO LIVE SITE ******************"
/nunset GIT_DIR
cd $LIVE
git pull origin master
/necho "********************* 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