23

I have two unsynced commits using GitHub (Windows), but don't want to commit them now. How can I revert or drop them?

screenshot

Sam
  • 6,961
  • 15
  • 44
  • 63
gezhonglunta
  • 1,011
  • 3
  • 11
  • 16
  • possible duplicate of [How do I delete unpushed git commits?](http://stackoverflow.com/questions/3197413/how-do-i-delete-unpushed-git-commits) – Sam Jul 29 '14 at 15:44

5 Answers5

23

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:

Undo most recent commit


As I mentioned in "GitHub undo a discard", the "discard changes" feature would achieve the same as a git reset.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 7
    And presto, the app is totally useless without this. – Gusdor Aug 04 '14 at 17:17
  • Worth noting that as of January 2014, these commands have no effect on unsynced changes in Github for windows. The only output is some line noise claiming that HEAD has been reset to some random commit from last month. Thanks for the help! Really made my day! – 15ee8f99-57ff-4f92-890c-b56153 Jan 06 '15 at 05:53
14

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.

drverboten
  • 305
  • 2
  • 7
5

Latest version of GitHUb for Windows have this option. The option will be enabled in case you have any unsynced commit. This is a very useful update from GitHub.

enter image description here

Agni
  • 370
  • 4
  • 14
2

There is an undo button. Right click on the file to commit and select "Discard changes".

https://github.com/blog/1441-undo-button-in-github-for-windows

Robin Donatello
  • 395
  • 2
  • 12
  • 1
    That's only if the changes haven't been committed, but the question is about how to un-commit changes that would otherwise be synced to the server on a git push. – David Mar 18 '15 at 05:37
2

I would suggest, based on the way the questions is phrased, and what searches it comes up for, that people may want to use "FETCH_HEAD when resetting via the git CLI/ ("Open in Git Shell") in the GitHub for Windows menu.

Once in the shell, run: git reset FETCH_HEAD --hard

This will reset you back to where you were when you last pulled down changes from your remote - which is what it seems like some people hitting this page are looking to do.

Will H.
  • 21
  • 1