How to use git to maintain a slightly different copy of production source code?

I have a Ruby on Rails application, which sends out emails.

In production, I want to use some X SMTP server, but in development I want to use some other SMTP server (thus my configuration file for the SMTP settings is different in the development and production environments)

So I need to maintain 2 configuration files (one file each for the development/production environments' SMTP settings).

As of now, I keep settings for Y STMP in a file on my development machine. I clone the production code from the github repo, modify the working copy with settings for Y SMTP and proceed. Then when I have to push changes to github, I reverse the process. It works, but I'm thinking there should be a better way?

What is the "git way" to handle this sort of "small differences" between development and production code bases?


UPDATE

Per @Mike Axiak, is this the flow that you mean: (presume for simplicity that I'm not using ln, but using the copy method)

Set up source code so that there are 2 settings files on local machine:

  • smtp.settings.prod
  • smtp.settings.dev

Both are added to .gitignore

To work on local copy:

  • Pull code from github
  • Copy smtp.settings.dev to smtp.settings
  • Use.

To push changes to server:

  • Just before push, copy file smtp.settings.prod to smtp.settings
  • Push

If this is what you meant, is there some way to automate the copying process via git?

5
задан Zabba 4 May 2011 в 02:58
поделиться