How to undo a mistake on GitHub
GitHub shows a couple of practical ways to undo an accidental commit, depending on whether you already pushed the change or not.
Overview
The video explains two common “undo” paths for commits, based on where you are in your workflow.
If you already pushed the commit
- Use GitHub’s Revert action to create a new commit that undoes the changes.
- This approach is positioned as a quick fix when the commit is already on the remote.
If you have not pushed yet
- Use a terminal command to take the commit back while keeping your work.
- The video calls out using a safe reset approach (commonly done with a soft reset).
bash git reset –soft HEAD~1
Related resource
- GitHub for beginners season 3 playlist: https://www.youtube.com/watch?v=r8jQ9hVA2qs&list=PL0lo9MOBetEFcp4SCWinBdpml9B2U25-f