I want to merge my dev branch into stage but there are some commits that should not go to stage. One solution is to use cherry-pick but there are just too many commits to cherry-pick so it is not feasible. Is there any solution to take my changes from dev to stage without merging dev completely into stage.
I tried to use cherry pick but the first one I did, it had conflicts. There is no way I am doing this with 300 commits.
Suppose you have this:
Suppose you want to merge
devintostagebut you do not want to include the changes fromeeeandddd.You could create a temporary branch and revert the commits from there:
Now you have this:
Now, we proceed to merge into
stage:And we get this:
Now, time has gone by and
devhas more commits:Say that at this point, you consider that you want to merge
devagain intostageand now that you are merging the full branch, you would expect to see the changes fromdddandeeeshow up in the branch, right? Well.... not really... that can't happen because those commits are already merged intostage. You can see that the commits are already in the history ofstage... another to look at it is by looking at the last common ancestor betweenstageanddev... where is it? It'sfffand only commits past this commit will be considered on the merge...dddandeeeare not pastfffand so you are out of luck..... you won't see those changes show up.... unless you come up with a magic trick.... you can undo the reversal that you did intempand merge it back intodev... something like[1]:And now you have a chart like this:
And now, starting from the same common ancestor between
devandstage, we have the changes fromdddandeeereapplied so when you merge, the changes will show up.[1] The reversal of all those commits could have been done with just a single command, instead of having multiple
git revert: