D
D
Dima nahkar2016-06-08 23:15:47
git
Dima nahkar, 2016-06-08 23:15:47

How to remove a specific commit?

Let's say I have a commit history of 1.2.3.4.5.6 How can I remove commit 3 so that 1.2 and 4.5.6 do not suffer?
It’s just that when I make a pull-request, in the middle of the history of commits and merges, there is a commit that I don’t need when I rollback, the commits in front are lost.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abcd0x00, 2016-06-09
@nahkar

Run a rebase -i to the parent of the commit you're deleting.
A window will open there, in which you will need to delete the line with the 6159eb3 commit.
After deleting, save and exit.
Remember that rebase creates all commits again, so you can apply it until no one has uploaded your commits to themselves, otherwise they will have duplicates of the same commits with different hashes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question