2

I have several a,b,c,d,e made and published. No I noticed errors and want to reset my entire project to commit b. Since it is published I read that I should not use reset to not re-write history. Revert, on the other hand, does only revert individual commits.

Is there way to revert all commits since commit b t once?

almo
  • 6,107
  • 6
  • 43
  • 86
  • 1
    Possible duplicate of [How to revert Git repository to a previous commit?](http://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit) – jopasserat Jan 28 '17 at 15:03
  • There's nothing wrong with using `reset --hard` to rewrite history; I do it plenty. You just need to be *absolutely sure* that there are no consequences to losing your work. – Pockets Jan 28 '17 at 19:20

1 Answers1

5

You can revert a range of commit by git revert <from-commit>..<to-commit>.

$ git revert -n c..HEAD

This reverts the changes done by commits from the c (included) to HEAD (included), but do not create any commit with the reverted changes. The revert only modifies the working tree and the index.

Then you need to commit :

$ git commit -m 'Revert commit from c to HEAD'

See More

Sajib Khan
  • 22,878
  • 9
  • 63
  • 73