{"thread":{"id":"40858","subject":"Best practice setup for github projects on server","startedAt":"2015-11-23T11:19:00Z","lastAt":"2015-11-23T21:32:21Z","messageCount":2,"participants":["Matthew Leach","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"273602","messageId":"8A5E5D5720EB7347BF290277F0C633F8010C7E55DFB4@MKT-MBX01.university.ds.derby.ac.uk","threadId":"40858","inReplyTo":null,"subject":"Best practice setup for github projects on server","fromName":"Matthew Leach","fromEmail":"m.leach@derby.ac.uk","sentAt":"2015-11-23T11:19:00Z","receivedAt":"2015-11-23T11:19:00Z","isPatch":false,"sender":{"key":"m.leach@derby.ac.uk","avatar":null},"body":"Hi,\n\nI was hoping that somebody could give me advice since I'm new to git.\n\nI'll be installing a couple of projects from github on our servers, and adding some features.\n\nShould I create a repository on our server (e.g. in /opt/git/), add the github project as a remote, and create a branch?  Then on my local machine add our server as the remote and then pull / push with that?\n\nOn the server there will be two web directories: stable and dev.  I was planning for these to be branches, and then just pull from the server repository using the local protocol.\n\nI think it would mean sorting out merge actions on the server.  I'm hoping to be able to fetch and integrate updates from the developer's github repository, but without making things more complicated than they need to be.\n\nDoes anyone have any suggestions?  I drew a diagram if it helps (https://drive.google.com/file/d/0B7JhUXLbxPT9RkVNMUV6cjJNVnc/view?usp=sharing)\n\nThanks\n\nMatthew\n\n\nMatthew Leach \nBSc. PhD. PGCert. FHEA\nInnovation Developer\n\nAcademic Innovation Hub\nRoom 107, Enterprise Centre, 37 Bridge Street, Derby, DE1 3LD\n\nThe University of Derby has a published policy regarding email and reserves the right to monitor email traffic. If you believe this was sent to you in error, please select unsubscribe.\n\nUnsubscribe and Security information contact:   infosec@derby.ac.uk\nFor all FOI requests please contact:   foi@derby.ac.uk\nAll other Contacts are at http://www.derby.ac.uk/its/contacts/\n"},{"id":"273622","messageId":"CAGZ79kar2BbLV6xnOz9HH+b-03Xu=EOagH1q3dsdLRFJxzS51Q@mail.gmail.com","threadId":"40858","inReplyTo":"8A5E5D5720EB7347BF290277F0C633F8010C7E55DFB4@MKT-MBX01.university.ds.derby.ac.uk","subject":"Re: Best practice setup for github projects on server","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-11-23T21:32:21Z","receivedAt":"2015-11-23T21:32:21Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, Nov 23, 2015 at 3:19 AM, Matthew Leach <M.Leach@derby.ac.uk> wrote:\n> Hi,\n>\n> I was hoping that somebody could give me advice since I'm new to git.\n>\n> I'll be installing a couple of projects from github on our servers, and adding some features.\n\nSo you take source code from github and improve it...\n\n>\n> Should I create a repository on our server (e.g. in /opt/git/), add the github project as a remote, and create a branch?\n\nYou can certainly do that. Why would you want to keep it on your\nserver though? (Is it not worth to be open because it's highly company\nspecific stuff? Is it closed intentionally because it would reveal\ncore company secrets? Is it just for backup, because you don't trust\ngithubs uptime?) Having 2 remotes (github and your server) makes the\nworkflow slightly more complicated, but if you don't mind a\ncomplicated workflow that's no problem. But be sure to know why/what\nbenefits you gain from that. You could also go with your github fork,\nwhich could be set to private, I'd guess.\n\n> Then on my local machine add our server as the remote and then pull / push with that?\n\nSure, sounds fine.\n\n>\n> On the server there will be two web directories: stable and dev.  I was planning for these to be branches, and then just pull from the server repository using the local protocol.\n\nBeware of that. There are quite a lot of servers serving the contents\nof the .git directory, you may or may not want to expose the history.\n(Certainly it looks odd)\nFor a private server I'd have the git directory somewhere non-public\n(outside of /var/www, so maybe in the home directory of the git user)\nand then a hook like this:\n\n    $cat .git/hooks/post-update\n    GIT_WORK_TREE=/var/www/your-stable-web-dir git checkout stable-branch\n    GIT_WORK_TREE=/var/www/your-dev-web-dir git checkout dev-branch\n\nThat's one way to do it. And outdated by now (as I just wrote down the\nconfig I have in a personal server).\nGit has learned a push-to-deploy[1], which should do what you want there, too.\n\n[1] https://github.com/blog/1994-git-2-4-atomic-pushes-push-to-deploy-and-more\n\n\n>\n> I think it would mean sorting out merge actions on the server.  I'm hoping to be able to fetch and integrate updates from the developer's github repository, but without making things more complicated than they need to be.\n>\n> Does anyone have any suggestions?  I drew a diagram if it helps (https://drive.google.com/file/d/0B7JhUXLbxPT9RkVNMUV6cjJNVnc/view?usp=sharing)\n\nAs said above, what exactly do you solve by having yet another line in\nthe diagram (with /opt/git/proj.git) ?\nYou can directly pull from github to the local developers workspace\n(and sort out merge conflicts there)\nand then push to deploy from the workspace, too.\n\nIf you need a place to share for just the subset of people in your\ncompany, you could use the /opt/git/proj.git for sure, but you'd\npull&resolve merge conflicts to your workstation and then push for\nsharing to your server.\n(Also think about external hosting solutions, if they make sense there)\n\nIf you dislike the push-to-deploy approach (not everybody should be\nable to push a new version, only a subset of people should be able to,\nthat should also work the same way as you would restrict the \"pull\ndev\" and \"pull stable\", I'd guess)\n"}]}