$0.34

How do I undo the most recent local commits in Git?

Ask a question+
0

I accidentally committed the wrong files to Git, but I haven’t pushed the commit to the server yet.

How can I undo those commits from the local repository?

add comment

1 Answer

0

To remove the last commit from git, you can simply run git reset —hard HEAD^ If you are removing multiple commits from the top, you can run git reset —hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

add comment

Your Answer