I'm wondering what's the bet way to integrate "Hotfixes" into the Git workflow.
It seems that all recommendations for Git workflow tutorials recommend that Hotfixes are both pulled to the Master branch and the development/feature branches.
However, what about hotfixes which fix a state of production which was replaced/changed/re-factored in the development branch anyway?
To give you an idea, what I mean:
Say, you deployed the following code to production
function fetchDogs() {
return cats;
}
Two weeks later you notice that you've mixed up cats
and dogs
. You create a hotfix branch for it, replace cats
with dogs
, push it to master and deploy it. So, far so good.
However, imagine that in the meanwhile you've noticed that the structure of your function is inefficient anyway, so on your development branch you had changed it to:
function fetchAnimals(whichAnimal) {
return animals[whichAnimal];
}
However, you cannot deploy that since it is not yet tested (or for whatever reason).
So, if you pull the hotfix to the development branch, you'll probably get a complete unnecessary and superfluous merge conflict. (And it happened too often in my projects that merge conflicts not solved carefully enough lead to unwanted artifacts in the code.)
If, however, you don't pull it, you cannot push to master anymore.
How to solve such situations?
(After having written my question I realized that this question How should gitflow hotfixes work? deals probably with the very same problem. Since, however, there is no real answer to that one, I though I'd give it a try anyway.)