I have two unsynced commits using GitHub (Windows), but don't want to commit them now. How can I revert or drop them?
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 HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.
You can simply remove that commit using option "d" or Removing a line that has your commit. In the latest git version there is no more option d. You need just remove lines with commits from rebase to delete them.
As mentioned in "How to reach some commands on Github for windows", you best course of action would be to use to git CLI (command line interface), opening a shell from "GitHub for Windows", or using msysgit.
Then a git reset HEAD^2
(or even git reset --hard HEAD^2
if you really want to remove those files as well as any work in progress) would drop those commits (as in "How do I delete unpushed git commits?" or "How to delete a 'git commit'").
After a refresh, GitHub for Windows should display no more unsynced commit.
Other answers below mention the recent addition of "Undo most recent commit
", which achieve the same reset:
As I mentioned in "GitHub undo a discard", the "discard changes" feature would achieve the same as a git reset.
In the newest version of GitHub (Windows) under the Settings button, next to the "Sync" icon/button there is the option "Undo most recent commit", that will take care of those unsynced commits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With