I commited accidentally to much, I added the changes and wanted to do git commit -m "foo" but i mistyped me and typed git commit -a -m "foo".
How can I revert this, without loosing the changes which I made?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
git reset HEAD^. This will get rid of the most recent commit in your current branch but keep your working tree intact.Note that this rewrites history. In case you already published that commit it and people pulled it, it’s be better to revert the commit by creating a new commit using
git revert HEADthat undoes the changes from the last commit.