1

I am using Git/Heroku for a work application. Usually, changes will be merged into master then pushed to staging then production. But now I need to push only selected changes (patches) to production. How should I do that?

  1. Some initial state in master
  2. Patch 1
  3. Patch 2
  4. Patch 3
  5. Patch 4
  6. Patch 5

My first thought was to pull from heroku/production. Copy changes here (eg. a subset possibly from patch 2 and 4) and then only push into heroku production. I think this will work, in the short term. But in the future how do I manage such "divergent" changes? Since now master and production is different. When I push from master into production, I guess I will get conflicts? Either that or I will end up overriding changes made on production? How are such changes managed?

Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

1 Answers1

0

But in the future how do I manage such "divergent" changes?

By creating a dedicated branch "prod" from which you cherry-pick the right commits you want from master (instead of a global merge)

Since now master and production is different. When I push from master into production, I guess I will get conflicts?

Yes: once you start cherry-picking commits, you shouldn't merge anymore.
(because of duplicate commits and functional dependencies)

The best reconciliation between those two branches is make master stable enough for it to replace the the prod branch (meaning you reset prod to master)

I do precisely that "double-branch" approach in my compileEverything project.

master and prod

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