Say I have A–B–C–D–E–F–G
on commit C there is “horizontal scrolling feature”. Later we changed our mind and on commit D there is “vertical scrolling”. Then E,F,G are back-end DB migration changes that do not effect the view.
But now we decide to give horizontal scrolling another chance, how do we get back horizontal scrolling? I don’t want to revert back to C, because I want to keep E,F,G. I want to forward merge C… I guess merge isn’t the correct term because C already exists in the history of this branch. I suppose I can do a checkout of the specific files from C into my current working directory, but that seems manual and I would have to remember which view files and css files were modified.
Is there a way to generate a patch difference between C and G and then apply it to the current working directory? Would that work? How do I do that?
Aside from already mentioned cherry-pick (@titaniumdecoy), there is interactive rebase:
git rebase -i C(meaning you get a chance to rewrite the history as if there was no D). It will of course cause merge problems if you already published the history (if there are already people with the history as in example). In this case cherry-pick might work if D was a revert (git revert C) of C. Otherwise, you’re better off reverting D:git revert D.