This content originally appeared on DEV Community and was authored by Pheak Pheasa
Way 1
1. Find your committed hash by :
git log
2. After found your commit hash you need revert it by :
git revert <commit-hash>
3. choose one at bellow with responsibility:
⸻
🟢 Uncommit last commit (keep files):
git reset --soft HEAD~1
✅ Files stay staged, just remove commit.
⸻
🟡 Uncommit & Unstage (keep changes in working directory):
git reset --mixed HEAD~1
✅ Files stay, but unstaged (not in commit).
⸻
🔴 Uncommit & Remove changes:
git reset --hard HEAD~1
⚠️ Files & commit both gone! Careful!
⸻
🟣 Uncommit pushed commit (force push):
git reset --soft HEAD~1
git push --force
✅ Removes commit on remote branch too.
⸻
Way 2 in next post.
This content originally appeared on DEV Community and was authored by Pheak Pheasa

Pheak Pheasa | Sciencx (2025-03-24T04:10:10+00:00) 2 Ways to save your life when you confused push any code or file to your branch.. Retrieved from https://www.scien.cx/2025/03/24/2-ways-to-save-your-life-when-you-confused-push-any-code-or-file-to-your-branch/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.