5

I am using the work flow introduced by Successful Git branch. I am confused about how to manage changes,like configuration in develop branch.

When I merge from master, to keep working tree clean I stash the changes. If I commit the changes, I should be very careful when I merge back master.

So is there a better way to manage private changes in git?

razeh
  • 2,725
  • 1
  • 20
  • 27
robotment
  • 163
  • 1
  • 7

3 Answers3

6

There are several options:

  1. Do not put private files under source control. For instance, if you need a config.ini with private changes for each developer, then create a file config.ini.template with example settings in the repository, then each developer should make a copy of it and amend the copy with private settings. The config.ini should be added in the .gitignore.

  2. Add the config.ini in the repo and use git update-index --assume-unchanged config.ini so that git will ignore any local changes in the file not try to commit the file.

  3. Add several config files in the repo for each environment, e.g. config-robotment.ini, config-kan.ini, config-produciton.ini and so on. Then use a command line parameter, or an environment variable, or something similar to allow your application choose which file to use.

And the point is - don't use branches for the configuration, otherwise it will be always painful to branch/merge during development.

kan
  • 28,279
  • 7
  • 71
  • 101
  • Thanks for your advice, but I am working on a project that added config file to git and I can't change that. Maybe I can try this on my own project. – robotment Sep 06 '12 at 12:16
  • @robotment Use the option 2 then, it doesn't affect repository, just your working copy. – kan Sep 06 '12 at 13:30
  • The config files is already in the repo, and use git update-indexc --assume-unchanged config.ini. If the upstream update config.ini, will local file update? – robotment Sep 07 '12 at 01:42
  • @robotment Update from upstream will raise an error, so you will be told to solve the conflict - this is very handy. – kan Sep 07 '12 at 07:37
1

For configuration file, the choices are resumed in "Git: keep specific files unmerged".

I prefer versioning different value files for each environment (here for each branch), that way I don't have to deal with merge (the value file "dev.config" would never be modified in master branch, where the value file "master.config" is used)

I also version a template file, in order for a content filter driver to generate the actual config file (which remains private and isn't version) on checkout of the branch:

smudge clean filter driver

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

Create and switch to a local branch with a different name, merge upstream master branch when needed.

linquize
  • 19,828
  • 10
  • 59
  • 83