I have a code public repository with the following structure, new features are implemented by breaking off a new branch from master and merging it back.
(bugfix) | U / (master) / | A--B--C--D--E...J--K | (production)
Lets say there is a bug in the commit which production is pointing to (B).
- What is the recommended/best way(s) to apply the bug fix to Production in Git?
- Is it possible to apply the bugfix(U) to later features/ commits (C, D, E and so on), if so what recommended way(s) on doing it?
(master) | A---B---C'---D'---E' ... J'---K' | (production)
- Is it possible to have the commit C point to U ?
(bugfix) (master) | | A---B---U---C---D---E ... J---K | (production)
if so how do i have the changes applied to C, D, E ..
(bugfix) (master) | | A---B---U---C'---D'---E' ... J'---K' | (production)
- Clarifying the question
- I don’t want to merge (U) to master, lets say this is because I don’t want (K) to be in production yet
- I will be moving production from C, D, E… to K not directly to K
I highly recommend to use online git playground to emulate your process, those emulators include: https://git-school.github.io/visualizing-git/#free (disclaimer: I’m not the developer of this site)
Firstly, I think those things could only happened with bad branch management.
If you don’t want
K to be in production yet, why would you merge/commit
K into the
To deal with this issue, you can
- Checkout and make a new branch(
dev) just like current
- Back to master branch, and reset head on
- Merge/Rebase your new
- Finally, it may looks like:
(bugfix, master) | A---B---U | (production)
(possible merge request commit, dev) | A---B---C---D---E ... J---K---L | (production)
Answered By – hide1nbush