Git: remove earlier commit but keep recent changes

前端 未结 8 1513
甜味超标
甜味超标 2020-12-03 10:50

I got some commits in my repository:

like:

A - Added Feature A
B - Removed Feature B
C - Redesigned Feature C
D - Added Feature D
E - Added Feature          


        
8条回答
  •  甜味超标
    2020-12-03 11:16

    If you only have changes locally, you're probably best off following a rebasing answer. If you've published the changes anywhere then you don't want to rebase because that will change history, meaning that everyone else will also have to rebase or you'll get your offending commit merged back in again.

    If other people have your commits, the cleanest thing to do is to revert the offending change, not to excise it altogether. Use git revert COMMIT_ID to create a new commit that undoes the changes you applied in COMMIT_ID.

提交回复
热议问题