I\'m using Github Desktop (previously called GitHub for Windows) and I made a bunch of changes to my local files. It became such a mess that I decided I just want to rollback my
When you open GitHub for Windows v2.0 (ancestor of GitHub Desktop) and select your repository in the leftmost column, you'll see all your previous commits in the 2nd column from the left. If you select one of those commits, in the right column at the top you'll see "Revert" which says, when you mouse over, "Create a new commit that reverts the changes in this commit." I don't think this is what you want to do since you don't want to revert the changes in that commit but rather revert the changes that haven't been committed yet. So don't do that. (When you select "Uncommitted changes" in the 2nd column, the "Revert" link is not there.
There are two options - the first is easy and the second is super-easy:
Easy - Select your repository in the leftmost column then click the gear icon in the upper right and choose "Open in Git Shell". The shell should open and be in the directory of your repository. From there you can type git reset --hard
to revert files modified since the last commit and then git clean -fd
to remove all files added since the last commit. Obviously, you may enter other git commands here as well.
Super easy - Select your repository in the leftmost column and then click "Uncommitted Changes" in the 2nd column to display your changed files at the right. If you right-click on any file you'll have an option to "Discard changes". (How one would know to right-click is beyond me.) If you right-click in the space next to "Files to commit" you'll have an option to "Discard all changes." Click that and presto, all your changes are wiped out and your local files will be back to where they were the last time you made a commit.
GitHub for Windows v3 has made the "super easy" answer above obsolete and, once again, figuring out what to do is just not obvious. This time, select your repository in the leftmost column and then click the "{#} uncommitted changes" link at the top just to the left of "History". This should give you a middle column like the one below. To discard your uncommitted changes you need to right click the "{#} changes" text above the list of list of modified files. (Clicking in the white space around that text does nothing.) Click "Discard all changes" and, once again, presto, all your changes are wiped out and your local files will be back to where they were the last time you made a commit. (By the way, right clicking any one of those listed files will enable you to discard the uncommitted changes for just that file.)
In keeping up with the times, Github for Windows has had a huge makeover, so here's a new answer. It's now called Github Desktop and the version numbers have started back at v1.0.0. So if you're running Github Desktop v1 then your UI is going to look a little different.
This super-handy, always-hidden little feature, however, is still there.
First, select your repository in the far-left dropdown in the black area. Make sure you then select the tab that says "Changes". Now you can right-click anywhere in the rectangle that contains "{#} changed files" and you'll get a pop-up that says "Discard all changes..." Click that and, presto, you're back to where you were the last time you made a commit.
Bonus: You can also right-click any of the changed files to get a pop-up that will enable you to "Discard changes..." for only that file. Click that and only that file will revert back to where it was at the last commit.
The Github Desktop documentation now includes information on how to discard changes. It is, however, incorrect! When you right-click an individual file the pop-up does not give the option to "Discard all changes..." as their screen shot seems to indicate. To discard all changes you need to do as I describe above.