Wil
Wil

Reputation: 5047

Creating a new commit from history

Let's say someone has updated the remote origin with some nonsense and I want to ignore it. My repo looks like

A-B-C-D

And the remote is

A-B-C-D-E-F

I basically want to ditch E & F, but keep the history, so hopefully the result would look like

      /-----\
A-B-C-D-E-F-G

I can't see how to reset or revert without replaying E & F on top. I can't see how to merge without keeping E & F's changes. G & D should be precisely the same basically.

Upvotes: 1

Views: 96

Answers (1)

mipadi
mipadi

Reputation: 410552

So, you want to undo the changes in E and F, but retain E and F in the history? Use git revert with the -n (no commit) option:

$ git revert -n $F
$ git revert -n $E
# Fix conflicts, check to make sure the reverts look good, etc.
$ git commit

Upvotes: 3

Related Questions