0

I face a problem, common I guess.

I have a project which is store in github.

I need it to run for: production, testing and different developers.

The project uses maven profiles to set some parameters.

The project has also a spring profile: currently only DEV which initialize a DB.

The project uses external software with specfic configuration files.

I need to have the project in production but being able to serve development versions.

The question: can I use git ignore locally within developers to distribute the code and still store the files in github?

Or would you have a different solution?

The actual question is: Can I use git ignore locally for some configuration files and still have the files on the main repository? Updated by only the production users?

mariotti
  • 410
  • 1
  • 5
  • 23
  • Publish (deploy) your build's output to a Maven repository like Nexus or Artifactory. From there pull the file when doing a deployment onto your app server (for example tomcat). The binary repository decouples the process that builds the release artifact(s) from the process that deploys it. – Mark O'Connor Dec 06 '13 at 00:26

2 Answers2

0

One way is to store:

  • one different configuration file per environment
  • one template file
  • one script able to detect the current environment the git repo is cloned in, and generate the actual configuration file (which isn't versioned) used for that local environment.

That generation can be automated on checkout, with a smudge script declared as a content filter driver.

enter image description here

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I am going to like this answer, for the time being it is the only one ;) but also because you got the problem beside my badly posted question. But a couple of details, I am closed source from start. I do not have templates (in particular for external software), I can write scripts. If I go this way, can I make it standard industry? – mariotti Dec 06 '13 at 22:37
  • @mario you could make it "standard industry", but I usually see that kind of config file generation as an ad-hock quick way to generate what you need and move forward. – VonC Dec 06 '13 at 22:43
0

The way we have solved this is with a configuration script that pulls the server-appropriate credential file for local, staging, or production from a separate repository.

After each server pulls the appropriate file, we rename it for consistency across the different environments, and then we have our settings file which is tracked by git include the credentials file.

Wade Williams
  • 3,943
  • 1
  • 26
  • 35