{"id":1267,"date":"2014-07-26T21:59:22","date_gmt":"2014-07-26T20:59:22","guid":{"rendered":"http:\/\/fbcs.co.uk\/?p=1267"},"modified":"2015-12-09T19:06:40","modified_gmt":"2015-12-09T19:06:40","slug":"website-version-control-with-git","status":"publish","type":"post","link":"https:\/\/wp.fbcs.co.uk\/website-version-control-with-git\/","title":{"rendered":"Website version control with Git"},"content":{"rendered":"
\n\tSome notes on using git<\/a> to manage development and production versions of a website on a Linux server, based on Using Git to manage a web site<\/a>. There seem to be several web pages with similar ideas out there: I don’t know who wrote it down first. And also with reference to Version Control with Git<\/cite><\/a> by Jon Loeliger.\n<\/p>\n \n\tI’ve adapted those ideas for the way I like to do things:\n<\/p>\n \n\tThe steps for setting it up are as follows. I’ll leave the setting of suitable permissions and use of sudo as an exercise for the reader.\n<\/p>\n \n\t\t\t \n\t\t<\/p>\n \n\t\t\t \n\t\t<\/p>\n Some notes on using git to manage development and production versions of a website on a Linux server, based on Using Git to manage a web site. There seem to be several web pages with similar ideas out there: I don’t know who wrote it down first. And also with reference to Version Control with […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[45,7,29,23],"tags":[],"_links":{"self":[{"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/posts\/1267"}],"collection":[{"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/comments?post=1267"}],"version-history":[{"count":19,"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/posts\/1267\/revisions"}],"predecessor-version":[{"id":1390,"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/posts\/1267\/revisions\/1390"}],"wp:attachment":[{"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/media?parent=1267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/categories?post=1267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.fbcs.co.uk\/wp-json\/wp\/v2\/tags?post=1267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\n
dev.example.org<\/code> and
www.example.org<\/code>. So the development version is also an active real-world website: my nginx configuration makes it only visible to me.\n\t<\/li>\n
\/var\/www\/website<\/code> and
\/var\/www\/website-dev<\/code> respectively.\n\t<\/li>\n
\/var\/www\/website.git<\/code>. It’s a git convention to use the
.git<\/code> extension for bare repositories.\n\t<\/li>\n<\/ul>\n
\n
\/var\/www\/website-dev<\/code>.\n\t<\/li>\n
\r\nmkdir \/var\/www\/website\r\ncd \/var\/www\/website-dev\r\ngit init\r\ngit add <all the appropriate files and directories>\r\n<\/pre>\n<\/li>\n
.gitignore<\/code> file, and add everything that shouldn’t be transferred to production, such as configuration files that specify the development database and debug settings. For a WordPress site, that probably includes most of the WordPress stuff.\n\t<\/li>\n
\r\ngit commit -a -m \"a message\"\r\nmkdir \/var\/www\/website.git\r\ncd \/var\/www\/website.git\r\ngit --bare init<\/pre>\n<\/li>\n
\/var\/www\/website.git\/hooks\/post-receive<\/code> containing:<\/p>\n
\r\n#!\/bin\/bash\r\nGIT_WORK_TREE=\/var\/www\/website git checkout -f<\/pre>\n<\/li>\n
\r\nchmod +x \/var\/www\/website.git\/hoots\/post-receive\r\ncd \/var\/www\/website-dev\r\ngit remote add live file:\/\/\/var\/www\/website.git\r\ngit push live +master:refs\/heads\/master\r\ngit push --set-upstream live master\r\ngit push live<\/pre>\n<\/li>\n
\/var\/www\/website-dev<\/code> are now in
\/var\/www\/website<\/code>.\n\t<\/li>\n
\r\ngit push live<\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"