{"id":1903,"date":"2013-10-13T10:01:23","date_gmt":"2013-10-13T06:01:23","guid":{"rendered":"http:\/\/nayarweb.com\/blog\/?p=1903"},"modified":"2014-12-14T05:40:15","modified_gmt":"2014-12-14T01:40:15","slug":"automatic-server-deployment-with-gitssh","status":"publish","type":"post","link":"https:\/\/nayarweb.com\/blog\/2013\/automatic-server-deployment-with-gitssh\/","title":{"rendered":"Automatic Server Deployment with Git\/SSH"},"content":{"rendered":"<p>Uploading your files to servers is a pain. I was using <a href=\"https:\/\/nayarweb.com\/blog\/2013\/upload-files-to-your-web-server-using-git\/\" target=\"_blank\">git-ftp<\/a> previously. But i wanted to use a pure git protocol coupled with ssh.<\/p>\n<p>Copy your existing working directory to your server in lets say \/var\/www to be served as web; make sure it contains a .git folder.<\/p>\n<p>on your local machine:<br \/>\n<code>git remote add myserver nayar@example.com:\/var\/www\/.git<\/code><\/p>\n<p>on your server:<br \/>\n<code>cd \/var\/www<br \/>\ngit config receive.denyCurrentBranch ignore<br \/>\nmv .\/.git\/hooks\/post-update.sample .\/.git\/hooks\/post-update<br \/>\nchmod a+x post-update<br \/>\n<\/code><\/p>\n<p>modify the contents of .\/git\/hooks\/post-update as follows<\/p>\n<blockquote><p>#!\/bin\/sh<br \/>\nGIT_WORK_TREE=\/var\/www\/ git reset &#8211;hard<\/p><\/blockquote>\n<p>The setting up is over. Lets test if it&#8217;s working:-<\/p>\n<p>on your local machine:<br \/>\nMake some changes to your local files<br \/>\n<code>git commit -a -m 'changing file x'<br \/>\ngit push origin master<\/code><\/p>\n<p>The files on your server should have been updated accordingly \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Uploading your files to servers is a pain. I was using git-ftp previously. But i wanted to use a pure git protocol coupled with ssh. Copy your existing working directory to your server in lets say \/var\/www to be served as web; make sure it contains a .git folder. on your local machine: git remote &hellip; <a href=\"https:\/\/nayarweb.com\/blog\/2013\/automatic-server-deployment-with-gitssh\/\" class=\"continue-reading\">Continue reading <span class=\"screen-reader-text\">Automatic Server Deployment with Git\/SSH<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[149,174,109],"class_list":["post-1903","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-git","tag-server","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/1903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/comments?post=1903"}],"version-history":[{"count":6,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/1903\/revisions"}],"predecessor-version":[{"id":2490,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/1903\/revisions\/2490"}],"wp:attachment":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/media?parent=1903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/categories?post=1903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/tags?post=1903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}