21

So i've got a develop branch with a commit that I want to revert. So I type in git revert <commit-hash>

But when it runs it says:

$ git revert 165702b305
On branch develop
nothing to commit, working directory clean

This commit has been tracked down as the culprit of a bug and id like to revert it, but for some reason its not working. Could it be corrupted somehow? Other answers and searches have not been able to help.

enrique-carbonell
  • 5,836
  • 3
  • 30
  • 44
Peter Foti
  • 5,526
  • 6
  • 34
  • 47
  • 2
    Is it possible all changes of this commit are already reverted in other commits and the same bug has got another origin? – Netch Apr 25 '14 at 19:33
  • you can try solution of previous questions: (1) http://stackoverflow.com/questions/4114095/revert-to-previous-git-commit (2) http://stackoverflow.com/questions/927358/how-to-undo-the-last-git-commit – enrique-carbonell Apr 25 '14 at 21:39
  • This question doesn't really have enough information to be able to tell what's going on. Maybe if you add the output of `git log --oneline --graph --decorate`, that would help, but I realize that this question is already way old. – TheWarriorNamedFoo Aug 14 '14 at 17:08
  • try `git revert --no-commit 165702b305..HEAD` to revert changes from 165702b305 till HEAD. If you are happy with the unstaged changes after reverting, commit. – boh Sep 10 '14 at 06:31

3 Answers3

3

I had the same issue.

Using the following snippet worked for me:

git revert --no-commit <commit-id> -n HEAD
Arthur Weborg
  • 8,280
  • 5
  • 30
  • 67
sudo
  • 1,581
  • 1
  • 10
  • 11
2

I following git command will be more specific. It will point out that the revert will start at the HEAD pointer (where the branch is at right now) and end with commit 165702b305:

git revert 165702b305..HEAD
TsviZan
  • 118
  • 7
-2

I had exact the same issue and the syntax below worked for me:

git revert -n master~5..master~2
Deniz Ozger
  • 2,565
  • 23
  • 27