top of page
INTERMEDIATE LEVEL
Q14: How do you undo the most recent commit in Git?
To undo the most recent commit in Git, you have a few options:
- You can use the command `git revert HEAD` to create a new commit that undoes the changes introduced by the last commit.
- Alternatively, you can use `git reset HEAD~1` to move the branch pointer back one commit, effectively removing the last commit. This operation discards the commit and any changes associated with it.
bottom of page