\n# change group ownershipng to www-data user, user _www for MacOSX\nsudo chown -R :www-data [path_to_your_source_code_directory]\nsudo chmod -R g+w [path_to_your_source_code_directory]\n<\/pre>\nAs a git user, you know that git requires your ssh public key to be added to git so you can pull\/push code. in this case, we need to add www-data user ssh key to git repository. please do it like you always do. After having www-data user ssh key added, you can execute following command to do initial git pull to accept git server.<\/p>\n
\n# add \/var\/www\/.ssh\/id_rsa.pub to your git deploy key then execute these line\ncd GIT_REPO_FOLDER;\ngit pull origin; # it will ask you to accept, choose yes.\nexit; # return to your user\n<\/pre>\nfinally, create php script like this (note : this is just an example for magento devsite update)
\n deploygit.php<\/strong><\/p>\n\n<?php\necho "\\n1.switch branch\\n";\necho(exec('git checkout devsite;'));\n\necho "\\n\\n2.update branch\\n";\necho(shell_exec('git pull origin devsite 2>&1'));\n\necho "\\n\\n3.clean cache\\n";\necho(exec('rm -rfv var\/cache\/*;'));\n\necho("\\n=======");\ndie("\\ndone!");\n?>\n<\/pre>\nplace it at root of your website source code, execute [you_web_site_base_url]\/deploygit.php to run script<\/p>\n","protected":false},"excerpt":{"rendered":"
Git is getting popular day by day and there are many web front-ends for git available on the internet. In this article, i will give you an alternative option to work with git directly from PHP, i think it can be handy in some cases. To start working with it, we will need to find…<\/p>\n
Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46,60,66],"tags":[],"aioseo_notices":[],"views":6,"_links":{"self":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts\/790"}],"collection":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/comments?post=790"}],"version-history":[{"count":0,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts\/790\/revisions"}],"wp:attachment":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/media?parent=790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/categories?post=790"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/tags?post=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}