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?

有帮助吗?

解决方案

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 reset or something similar. If you're using Github for windows, a similar option is called revert.

Although, you should consider that if your commit have been pushed and shared with other devs, you shouldn't use reset as this could create trouble with the repo history of your collegue (revert command 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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top