It is always been said that learning curve of Git can pose a challenge. However, Git has always been an exciting tool, that has enhanced developers ability to work together and ship faster. In the mean time, developers are challenged to undo what they did in past. Likewise, undo-ing commits already made on Git. Here’s a solution, we have put together some useful ways on How to Undo Git Commits.
Undo a git commit and redo
$ git commit -m "Something terribly misguided" (1)
$ git reset HEAD~ (2)
<< edit files as necessary >> (3)
$ git add ... (4)
$ git commit -c ORIG_HEAD (5)
- So, you’ve made a commit and now it has to be removed.
- This leaves your working tree (the state of your files on disk) unchanged but undoes the commit and leaves the changes you committed unstaged (so they’ll appear as “ Changes not staged for commit ” in git status and you’ll need to add them again before committing). If you only want to add more changes to the previous commit, or change the commit message ,