How to use git to support a slightly different copy of the product source code?

I have a Ruby on Rails application that sends 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 SMTP settings is different in development and production environments)

Therefore, I need to support 2 configuration files (one file for SMTP settings for the development / production environment).

At the moment, I save the settings for Y STMP in a file on my development machine. I clone the production code from the github repository, change the working copy with the settings for Y SMTP, and continue. Then, when I need to make changes to github, I cancel the process. It works, but I think there should be a better way?

What is git to handle such “small differences” between development and production code bases?


UPDATE

Per @Mike Axiak, this is the thread you have in mind: (suppose for simplicity that I am not using ln, but using the method copy)

Configure the source code so that there are 2 settings files on the local computer:

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

Both added to .gitignore

To work with a local copy:

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

:

  • , , smtp.settings.prod smtp.settings

, , git?

+5
5

Rails , /. .

+5

, , .prod .dev. ln ( Windows) . git ( .gitignore)

+3

, , , settings.conf.dist, settings.conf .gitignore. , , cp settings.conf.dist settings.conf ( git) , .

, //. , , , , .dist, settings.conf. , , .

: , . , , , .

+1

, Gitorious, configuration/environments, RAILS_ENV script , , .

, . .

, , , . dev.mycompany.com vs test.mycompany.com vs mycompany.com , , .

+1

. .bash_aliases.

git clone
git checkout -b production.conf

config.file .

git commit -a
git checkout master

Do something with a working copy.

git checkout production.conf -- config.file
git commit -a
git push
0
source

All Articles