2

I have two branches: one for development and another for production, each one has its own config values in app.config file

what I want is to ignore these values whenever I merge or rebase these branches.

Christian
  • 164
  • 1
  • 10
  • 2
    Then perhaps you best bet would be to not even version the `app.config` file in the first place. Is there any reason why it is currently being versioned? – Tim Biegeleisen Feb 18 '19 at 15:49
  • @TimBiegeleisen , yes because it has other than these config values and I want them to be shared with other team members – Christian Feb 18 '19 at 15:53
  • 1
    Then maybe have one versioned file for common properties, and other config files which can be branch specific. – Tim Biegeleisen Feb 18 '19 at 15:54
  • @TimBiegeleisen , OK thanks, I got this solution in mind but I was wondering if there is a better way to achive that – Christian Feb 18 '19 at 15:55
  • 1
    If your app.config file differs from the one that is versioned consider having a separate unversioned app.config for your local development (if I understand correctly that the versioned app.config is for production) – LinFelix Feb 18 '19 at 16:38

1 Answers1

2

Then perhaps you best bet would be to not even version the app.config

Exactly, but you can still generate it, with a content filter driver, using .gitattributes declaration.

What you would version is a template file, and a file with all possible values per environment (per branch).

smudge (image from "Customizing Git - Git Attributes", from "Pro Git book")

The generated actual file remains ignored (by the .gitignore): your actual working tree does not get "dirty".

The smudge script:

  • detect the right branch
  • selects the correct value file and generates the correct file based on the template the smudge script is applied on during a git checkout.

That way, you modify the config.<branch> value file as much as you want: the config file (not versioned) will be generated from those values.
And it won't have any merge issue.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250