Delete earlier commits in Git
I want to delete a couple of earlier commits. This is what my repo looks like now -
R----A----B---开发者_如何转开发-C----HEAD.
I want to remove commits A and C and also discard changes made by them. This is how my repo should look like -
R----B-----HEAD.
How can I do this in Git?
Thanks.
Use git rebase -i R
, delete the A
and C
lines and save.
See Interactive Rebasing from Git Community Book and reorder commits with rebase from git ready for details.
精彩评论