How do I undo the last commit that I haven't pushed yet? #7
-
|
Hi! I am following the tutorial (Phase 3: Git Branching & Merging). I made a commit locally, but I realized I made a mistake in it. I haven't pushed it to GitHub yet. How can I undo this commit so that I can fix the files and commit again? Should I use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
To undo your last local commit (that hasn't been pushed to GitHub yet), you can use the 1. Undo the commit but KEEP your changes (Recommended)If you want to keep the work you did in the files so you can edit and commit them again, run: git reset --soft HEAD~1 |
Beta Was this translation helpful? Give feedback.
To undo your last local commit (that hasn't been pushed to GitHub yet), you can use the
git resetcommand. There are two main ways to do this depending on what you want to do with your changes:1. Undo the commit but KEEP your changes (Recommended)
If you want to keep the work you did in the files so you can edit and commit them again, run: