-1

I have two major branches for my project - master for the "production" version of the web app, and branch X for the "test" version of the app.

I need to keep some code tweaks related to deployment settings, database configs, Google Web Analytic IDs etc in these two branches separate from each other, and prevent them from being merged whenever git merge X happens on master or git merge master is executed on branch X.

Is there a reliable way to do that, i.e. mark some commits as "for this branch only"?

alexandroid
  • 1,469
  • 2
  • 15
  • 32

2 Answers2

3

Simple answer : not trivially.

Instead, you can either :

  • Cherry pick each commit, excluding the marked ones (a keyword in commit message for example)
  • Make a second branch without these commits and regularly merge it with the branch including them. Merge the "bad commits free" branch with master and the new one.
theor
  • 1,545
  • 1
  • 9
  • 16
  • Thank you! So do I understand correctly that by second option I need to have... let's see... 6 branches? Assuming M = Master and D = Development, D <= ConfigD + DClean, M <= ConfigM + MClean, so I would develop on DClean, and merge it into D and MClean? I suspect this ultimately will create conflicts every time I merge ConfigD into D to bring the config back... – alexandroid Apr 25 '12 at 17:23
  • Honestly, I would prefer the cherry-pick solution. It will be much simpler. http://wiki.koha-community.org/wiki/Using_Git_Cherry_Pick – theor Apr 25 '12 at 20:51
1

It's not ideal, but I have a similar scenario in one of my projects. My solution has been to maintain three branches instead - master, devel, and config. The config branch branches from some point on devel and contains only the configuration stuff (hence the name). Then I can develop and merge between master and devel as you indicate, and when I need to test, then I use rebase to move the config branch out to the tip of devel.

It's a little more cumbersome, especially if you're one who likes to test every commit on devel, rather than just testing periodically, but it's functional, at least.

twalberg
  • 59,951
  • 11
  • 89
  • 84
  • yeah, sounds like having more branches is the way, except maybe I'd like to have separate configs for master and development... thanks! – alexandroid Apr 25 '12 at 17:22