git revert commit_B_hash
Maybe you need to resolve the conflicts manually.The commit history remains unchanged, still being A -- B -- C -- D, but the changes made in commit B are reverted, retaining only the changes from commits C and D.