View 3+ more - How do I undo the most recent local commits in Git?

View 2+ more / git / version-control / git-commit / undo

I accidentally committed the wrong files to Git, but didn't push the commit to the server yet.

87 revs, 58 users 13%

Answer #1

Use git-gui (or similar) to perform a git commit --amend. From the GUI you can add or remove individual files from the commit. You can also modify the commit message.

If you haven't yet pulled other changes onto your branch, you can simply do...

git revert --no-edit HEAD

Also note: You don't want to do this if someone else may be working on the branch.

git push --delete (branch_name) ## remove public version of branch

Clean up your branch locally then repush...

git push origin (branch_name)