threads / discuss / 21492

suggestions for local configs?

Subject: suggestions for local configs?

## tl;dr

2 messages between Nov 6, 2009 and Nov 6, 2009.

replies: 1people: 2as markdown or json

Tim Rupp· Nov 6, 2009, 03:11 UTC · lore

Hi list, I'm wrestling with a question and figured that someone on the list may have some suggestions that have worked for them.

I have a piece of software that has default and local configuration files. The default files ship with the tarball. The local files are copied over from the default folder during installation and can be modified for a particular install.

I clone my source repo on my test and prod systems, but have gotten in the bad habit of versioning the local configuration files. My (albeit pathetic) excuse is that when I test the code I may accidentally dork with the local config files and need to revert back to the correct ones.

At the same time though, I do want to version said local configs in something so that if changes are made and they need to be backed out, it can be done and there is the commit log that keeps track of what changed.

So the question is
- Can anyone suggest good ways of setting up git to track both the code
and local configs without making a whole new repository (code repo and
code config repo)

If not, any other suggestions are welcome and I'll consider how best to make them work in my environment.

I've briefly skimmed through the pro git book online and considered sub modules and sub-tree merging, but the kicker is that I may need to push the whole kit-n-kaboodle master repo to remote git servers and those two approaches sound hairy.

Any help is appreciated.

Thanks, Tim

Johannes Sixt· Nov 6, 2009, 07:21 UTC · re: Tim Rupp · lore

Re: suggestions for local configs?

Tim Rupp schrieb:
> I have a piece of software that has default and local configuration
> files. The default files ship with the tarball. The local files are
> copied over from the default folder during installation and can be
> modified for a particular install.

This is how *I* would organize it, but it is a bit overengineered if the changes needed in the configuration are only minimal:

  ---o--o--X1--o--o--X2--o          master (aka upstream)
      \     \             \
       R-----M1------------M3       rename
        \     \             \
         Y-----M2------------M4     production
We need two branches in addition to master, which tracks upstream version.
1. The first branch *renames* the example configuration to the effective
configuration:
   git mv foo.conf.example foo.conf
   # commit R
   git commit -m "Use the example configuration"

It is important that *no change* is made to the configuration file, and it furthermore assumes that the production configuration (foo.conf) does not exist [*].

The point of this commit is that git can determine that the file was renamed with 100% similarity.

2. The second branch is actually where the customization happens, this is
commit Y:
   git checkout production
   edit foo.conf
   # commit Y
   git commit -m "configuration changes needed in production"

Assume, upstream made changes to the configuration (commit X1). These changes are merged in the following way:

1.  git checkout rename && git merge master

This creates M1. git detects that on our side the file was renamed, and merges the upstream changes into the renamed file. Since we didn't modify the file in R, there are no conflicts.

2.  git checkout production && git merge rename

This creates M2. This is a regular merge that integrates upstream changes with the local changes made in Y, possibly with conflicts.

You repeat the procedure when upstream makes more changes to the example configuration in X2. This time, git merge again detects that the file was renamed with 100% similarity, and things work just like with M1 and M2.

[*] If there is a configuration file in addition to the example configuration, another branch is needed that removes it.

-- Hannes

← back to recent threads