Search code examples
gitgithubgit-commit

How can I cancel the accidental commit to dev branch (hasn't pushed it yet)?


I'm not supposed to commit to dev branch directly, but I accidentally committed something but hasn't pushed it yet, what should I do if I want to cancel it without affecting anything else?

I found a command online: git reset --hard HEAD^ can I use it?


Solution

  • You can just use it without --hard flag

    git reset HEAD~1