Search code examples
gitcommitrevert

How to remove/revert commited changes to local git repo


I've committed some changes to local git repo with command git commit -m "Change X"

Question: Is it possible to revert/remove this change from local git and my working directory?

I know I can use git commit ammend to rewrite this commit, but I want to delete it, I dont want to put it to remote repo.


Solution

  • Try like this,

    Undo your commit, files and your index.

    git reset --hard HEAD~1
    

    Undo your commit but leave your files and your index.

    git reset --soft HEAD~1