开发者

Creating a new commit from history

开发者 https://www.devze.com 2023-01-14 05:14 出处:网络
Let\'s say someone has updated the remote origin with some nonsense and I want to ignore it. My repo looks like

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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消