Is there any way to undo the effects of “git revert head”?

I’ve accidentally run the command against the wrong branch in my repository – is there a way to undo this change?

  • How to version project schedules, to-dos, wikis etc. in Git?
  • How can I make this git command alias?
  • Practical uses of git reset --soft?
  • hudson/jenkins keeps building the bad branch in git instead of the good one
  • Team Foundation Server 2012 and GIT
  • Resharper cache and GIT branches
  • bulk delete in GIT?
  • GitLab webhook error 'Hook Execution Failed'
  • How to Clone a TFS Repository with a Hyphen in the name Using git-tf
  • npm install private git repository with .git folder and .gitignore file
  • Revert git remote accidentally pushed repository changes
  • After splitting a repo, new repos are many time larger
  • 3 Solutions collect form web for “Is there any way to undo the effects of “git revert head”?”

    git revert just creates a new commit — you can “remove” it with git reset --hard HEAD^ (be more careful with it, though!)

    The command git revert just creates a commit that undoes another. You should be able to run git revert HEAD again and it’ll undo your previous undo and add another commit for that. Or you could do git reset --hard HEAD~. But be careful with that last one as it erases data.

    HEAD~ means the commit before the current HEAD

    How about reverting the revert?

    View git log and get the hash tag of the bad revert:

    git log -5

    Then do reverse the revert itself:

    git revert

    Git Baby is a git and github fan, let's start git clone.