Pushing selected changes to production

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?

  • Version control system capable of handling file moves?
  • Concerning workflow of a second commit without a previous push
  • How to handle shared code with Git in this scenario?
  • GitLab: is there a way to assign a status/comment to a branch?
  • Which files should I tell my VCS to ignore when using Sphinx for documentation?
  • Start from GitHub repo, clone it privately in BitBucket, and also grab changes from the original?
  • How to make GIT treat directory junctions as regular folders on Windows?
  • Git Merge: Is it better to delete parts of a branch and merge, or to force merge and overwrite?
  • One Solution collect form web for “Pushing selected changes to production”

    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

    Git Baby is a git and github fan, let's start git clone.