How can I deploy a bug fix to production without merging other commits from main?

0
7
Asked By TechyTurtle2021 On

Hey everyone, I'm facing a bit of a dilemma. We have a main branch that's currently in production, but there are two new commits that have been pushed to it via pull requests. Now, a bug has come up in production that needs an urgent fix, and while I've got the fix ready, it hasn't been merged into the main branch yet. The tricky part is that I only want to deploy this fix without including those two newer commits from the main branch. Any suggestions on how to go about this? Here's a quick rundown of my branch structure:

- BugFix (this is the urgent fix I want to deploy, without the preceding 2 commits)
- wave1 feature code
- wave1 enhancement
- main (the version deployed to production)

I've thought about some options, like commenting out the code from the two newer commits in a new commit with the fix or creating separate branches for releases. What are your thoughts? Thanks!

1 Answer

Answered By DevDynamo99 On

You could create a new branch from the commit on main that’s already live in production, maybe something like "hotfix-". Then merge your bug fix into that branch and deploy it directly to production. After ensuring everything's stable, you can merge that "hotfix" branch back into main. Just make sure you adjust your branching strategy so that no unstable commits end up in main when you're deploying.

FixItFelix42 -

Just a heads-up, though, if it's a zip archive with no .git directory, finding the last production commit could be tricky. You'll need to keep track of that outside of Git.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.