1

Our team is stupid and pushes all develop branches into master. Master reflects all environments, dev/qa/prod. We need to perform a hotfix in prod and not bring along all the other changes.

So I want to checkout the production sha, add some changes, and push to master and run it all the way up to production. Problem is I'm getting merge conflicts and I'm behind master.

git checkout <<sha>> -b update-prod
// add my changes
git add .
git commit
git push

Definitely missing a step but I feel like this is totally doable and I'm just not understanding how to do this from the documentation I'm finding.

cWerning
  • 583
  • 1
  • 5
  • 15

1 Answers1

1

No I'm not. I want to get the change in prod and then add back the changes and put them in dev/qa

Then create your hotfix branch from prod, and merge it back to prod directly, as well as master.

But consider also gitworkflow (one word), in which that kind of merge is a natural occurrence: you would not merge dev to qa, qa to prod: you would only merge feature branches or hotfix branches directly to the relevant environment (dev/qa/prod) branches.
See more at rocketraman/gitworkflow

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I'm pushing gitflow to the lead engineers for the past month. Master branch gets deployed to dev/qa/prod. – cWerning Jul 14 '21 at 21:24
  • So I can create a branch from the master branch sha that's in prod, but I don't know how to get it back up to prod – cWerning Jul 14 '21 at 21:25
  • @cWerning by merging the hotfix branch to prod directly, without using dev/qa, since it is an hotfix intended for prod. – VonC Jul 14 '21 at 21:48
  • @cWerning gitflow is not a good workflow, for reasons highlighted and explained in gitworkflow: https://stackoverflow.com/a/53405887/6309. You bring too much at each merge (dev to qa, qa to prod). And removing features along the way is too hard. – VonC Jul 14 '21 at 21:49
  • dev/qa/prod are environments, not branches. I have to go through master to deploy to prod – cWerning Jul 14 '21 at 21:51
  • @cWerning OK. In this case, merge to prod directly. – VonC Jul 14 '21 at 22:00
  • That's not possible in my case. I figured this would be able to be completed all through git but I guess I'm just going to have to cherry pick changes and deploy to master. – cWerning Jul 14 '21 at 22:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/234876/discussion-between-vonc-and-cwerning). – VonC Jul 14 '21 at 22:03