I have history like that:
A <- B <- C <- D <- F
where F is newest.
B
and C
cancel each other out (really its 3 commits: merge feature to master, revert the merge commit, merge pr containing the reverting commit), so that:
git diff A D
shows no diff at all.
So it seems that applying D and F on top of A should be trivial. I want to get A <- D <- F (there's actually more commits after F).
- I've tried cherry-picking
git reset --hard A
git cherry-pick D F
and this is not trivial, as among D and F commits there's merge commits and git cherry-pick
asks for additional info on which commit is to be treated as mainline.
- I've tried rebasing
git branch -c branch_A A
git branch -c branch_D D
git rebase --onto branch_A branch_B branch_C
which based on git rebase docs should do exactly what I want. Yet still im getting conflicts to fix.
How do I do that and why is it hard?
I simply want the worktree after every re-applied commit to be exactly the same as worktree in the master branch at the same commit.Worktree's start from the same state at commits A or D and I want for every commit applied to D to do exactly the same as it was applied to A.
thanks in advance
EDIT: let me ask here a different but connected question.
As really the problem I have is to merge a reverted commit again to the branch. This is impossible now as the commit already exists in the history, so the merge results in no conflicts but no change at all, for git this is merged already in the past.
How do I do this merge? Maybe I shouldn't try to remove the commits from main branch, but rather modify a feature branch so that its no longer recognizable as something that was already merged? Will this route be easier?