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

View 3+ 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

If you are planning to undo a local commit entirely, whatever you change you did on the commit, and if you don't worry anything about that, just do the following command.

git reset --hard HEAD^1
git reset --soft HEAD^1

Now your committed files come into the staging area. Suppose if you want to upstage the files, because you need to edit some wrong content, then do the following command

git reset HEAD