Explore Courses Blog Tutorials Interview Questions
+3 votes
in DevOps and Agile by (19.4k points)
edited by

I have a git repository that looks like this:

A -> B -> C -> D -> HEAD

I want the head of the branch to point to A, i.e. I want B, C, D, and HEAD to disappear and I want head to be synonymous with A.

It sounds like I can either try to rebase (doesn't apply, since I've pushed changes in between), or revert. But how do I revert multiple commits? Do I revert one at a time? Is the order important?

1 Answer

+3 votes
by (27.5k points)

The following command will revert the last 3 commits with only one commit.  

$ git revert --no-commit HEAD~3..    

Browse Categories