7

I've spent the past week reading up on Git and trying to figure out how to fit it into our company. There's a lot of information out there, and among other resources I found the Pro Git book very useful. However, one thing that remains a mystery to me (it's not in the book either), is how to 'link' the Git repository to our production servers.

Our current setup consists of one SVN server, that we all commit to (I found this can be equalled by setting up a bare Git repository in a shared location, and pushing to it). Our production servers (there are multiple customers running the same PHP codebase) are currently SVN working copies, that we update manually one at a time by running svn up.

What would the best way to approach this in Git? I thought about adding the production servers as remotes in my Git repository and pushing to them, but I think this could potentionally create confusion if the different servers get different push histories (this would be one occasion where you would actually need it to be centralized I guess). Or do you need to use a tool like https://github.com/mislav/git-deploy?

I can't help but feeling the Git developers 'didn't really thought about this'.. I hope I'm missing something :)

Community
  • 1
  • 1
Rijk
  • 11,032
  • 3
  • 30
  • 45
  • Hey, I have a quick question. I just want to verify. I wasn't sure if that was right, but it is completely fine to and you should have a git repo in your production server to push your files right? I mean this question answers it subtly, but I want to actually here a yes haha. I appreciate it. – Andy Jun 26 '12 at 03:22

1 Answers1

6

You can achieve the same work flow with git. Setup a bare repo that you all push your code to and clone that repo on your production server. When something has happened and you want to update your production repo just do "git pull" instead of "svn up".

This is a good start to just get things going. After a while you might want to automate this and you can do lots of cool things with e.g. git hooks.

rtn
  • 127,556
  • 20
  • 111
  • 121
  • This might be also interesting for you: [A web-focused Git workflow](http://joemaller.com/990/a-web-focused-git-workflow/) – hakre Mar 09 '12 at 11:31
  • @hakre indeed an interesting demonstration of hook scripts (although I wouldn't go with this workflow, as we never directly modify the code on production servers) – Rijk Mar 09 '12 at 12:43
  • I have a related question. Say, you use a deployment tool like "BeanStalkApp" or "SpringLoops.com" . You check-in your code to Git and then use Beanstalkapp or Springloops to ftp/sftp your code to deployment server. But what if you also have DB changes? How do you ensure that DB changes are also done on deployment server? Git pull or BeanstalkApp/Springloops will simply send your new php files. But if you also need to make your changes to db, how do you accommodate that in auto-deployment? Say, you add/remove table, add/remove columns. @hakre – Red Char Mar 10 '12 at 20:02
  • Make revisions of your database. Migrate it with migration scripts. Either one-way (only revisions up) or both ways (revisions up and down). One php script checks DB revision and takes care. http://dbdeploy.com/ -- [How do you version your database schema?](http://stackoverflow.com/questions/175451/how-do-you-version-your-database-schema) – hakre Mar 10 '12 at 21:38