I’m new to Git and using the Windows Gui.
After making several commits, I made an uncommitted change I don’t like.
How do I fetch my last local commit and overwrite the working copy with it?
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.
On the command line, you would have to call
git reset --hard HEAD^to go back one commit.So, in your GUI tool, you’ll probably have an option called
resetor something similar. If you’re using Github for windows, a similar option is calledrevert.Although, you should consider that if your commit have been pushed and shared with other devs, you shouldn’t use
resetas this could create trouble with the repo history of your collegue (revertcommand from github GUI would be fine in such a case). But no trouble if it’s only local.EDIT
In git-gui as this is the GUI used, you have the option “Revert Changes” under the “Commit” menu. As of more, you also have “Amend Last Commit” in the same submenu, and if you only want to go back to your previous clean state and remove all uncommited changes, you have the “Reset” option in the “Branch” menu.