1

I wan to use a reverted history commit.

Let's say this is my commit tree

A -> A' -> B -> C -> D

I made a commit A and reverted it by A'. Now, I am at D and I want my commit tree to be like

A -> A' -> B -> C -> D -> A'', where A'' is as same as A.

To summarize, I want to use a history commit.

I cannot simply checkout to A because I hope B, C, D be included.

I tried git cherry-pick, but B, C have conflicts with A.

My question is: How should I use cherry-pick to transform my commit tree to A -> A' -> B -> C -> D -> A'', without solving conflicts manually? (I tried git cherry-pick -X ours and git cherry-pick cd003861 --strategy-option theirs but failed.)

PQMeng
  • 61
  • 4
  • 3
    There may not be a way to reapply this commit without merge conflicts. – Tim Biegeleisen Oct 08 '20 at 06:53
  • 2
    Git isn't magic; if B, C or D introduced changes that mean A can no longer cleanly be applied, then you will have to resolve that yourself. – jonrsharpe Oct 08 '20 at 06:56
  • 1
    git checkout myhistoryversion -b. then: git merge master. – Steve Tomlin Oct 08 '20 at 06:59
  • 2
    Reminder : conflicts are **not** errors. – Romain Valeri Oct 08 '20 at 07:35
  • 1
    As everyone says, "conflicts" (harsh term) is just gits way of asking you for help. One option is that you've resolved those conflicts previously and enabled `rerere`, and taught git how to merge certain changes. But probably rarely does git have all the merge-conflicts-resolution info it needs for your scenario to always succeed. Theoretically, with `rerere` enabled and prior knowledge of conflict resolution for these concrete cases, it would be possible to do what you want. – zrrbite Oct 08 '20 at 15:53
  • Thank you all for your swift responses. To clarify, handing **conflicts** manually is impossible in my case, as there are so many files. Therefore, I am seeking approaches similar to ```git push -force```. Seems like there are no ways of doing that. – PQMeng Oct 08 '20 at 17:24
  • Can you explain "I hope B, C, D be included" ? – LeGEC Oct 08 '20 at 22:22

0 Answers0