How to remove unsynced commits in github for windows?
Asked Answered
N

5

24

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

screenshot

Nod answered 20/2, 2013 at 2:38 Comment(1)
possible duplicate of How do I delete unpushed git commits?Noheminoil
D
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.

Drypoint answered 20/2, 2013 at 7:42 Comment(2)
And presto, the app is totally useless without this.Lightfoot
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!Telegraph
S
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.

Slavic answered 31/3, 2015 at 4:39 Comment(0)
S
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

Synecology answered 29/6, 2015 at 5:34 Comment(0)
R
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

Revile answered 12/3, 2015 at 22:47 Comment(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.Beaird
P
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.

Pronto answered 16/6, 2016 at 16:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.