Revert changes based on multiple commit selection
How can I revert multiple Git commits? - Stack Overflow
Revert commit on Website
git - Going back to a previous commit in Github Desktop - Stack Overflow
Expanding what I wrote in a comment
The general rule is that you should not rewrite (change) history that you have published, because somebody might have based their work on it. If you rewrite (change) history, you would make problems with merging their changes and with updating for them.
So the solution is to create a new commit which reverts changes that you want to get rid of. You can do this using git revert command.
You have the following situation:
A <-- B <-- C <-- D <-- master <-- HEAD
(arrows here refers to the direction of the pointer: the "parent" reference in the case of commits, the top commit in the case of branch head (branch ref), and the name of branch in the case of HEAD reference).
What you need to create is the following:
A <-- B <-- C <-- D <-- [(BCD)-1] <-- master <-- HEAD
where [(BCD)^-1] means the commit that reverts changes in commits B, C, D. Mathematics tells us that (BCD)-1 = D-1 C-1 B-1, so you can get the required situation using the following commands:
$ git revert --no-commit D
$ git revert --no-commit C
$ git revert --no-commit B
$ git commit -m "the commit message for all of them"
Works for everything except merge commits.
Alternate solution would be to checkout contents of commit A, and commit this state. Also works with merge commits. Added files will not be deleted, however. If you have any local changes git stash them first:
$ git checkout -f A -- . # checkout that revision over the top of local files
$ git commit -a
Then you would have the following situation:
A <-- B <-- C <-- D <-- A' <-- master <-- HEAD
The commit A' has the same contents as commit A, but is a different commit (commit message, parents, commit date).
Alternate solution by Jeff Ferland, modified by Charles Bailey builds upon the same idea, but uses git reset. Here it is slightly modified, this way WORKS FOR EVERYTHING:
$ git reset --hard A
$ git reset --soft D # (or ORIG_HEAD or @{1} [previous location of HEAD]), all of which are D
$ git commit
Clean way which I found useful
git revert --no-commit HEAD~3..
git commit -m "your message regarding reverting the multiple commits"
This command reverts last 3 commits with only one commit.
Also doesn't rewrite history, so doesn't require a force push.
The .. helps create a range. Meaning HEAD~3.. is the same as HEAD~3..HEAD
In general, you can go back to a commit in your history with git reset.
This is not possible with GitHub Desktop. GitHub Desktop is more of a tool to synchronize your repositories and not a full featured GUI client.
But that doesn't mean you have to use the command line, since there are alternatives. You can find a list here. To mention a few (that support git reset):
- TortoiseGit (Windows)
- SourceTree (Mac, Windows)
Here is how you do it on command line. Most clients provide this in their UI using the same vocabulary (usually, you are able to select a commit and reset to it via context menu).
You will go back to the previous commit with
git reset HEAD^
or some more commits (for example 3) by
git reset HEAD^3
or to a specific commit by
git reset f7823ab
Have in mind that, by default, the option --mixed is passed to git reset. So, all changes made, since that commit you reset to, will still be there.
To get the original state of the commit that you want to 'revert', you have to pass --hard. For example:
git reset f7823ab --hard
If you have a commit that you have not pushed, it is easy to undo the commit. The "undo" button appears when you have such a commit. It removes the commit from the branch's history and places the files back into the Changes area.

I have GitHub Desktop and I have been making regular commits. Now a bug was introduced and I want to go back and get the whole project as it was in time at a previous commit.
How to do that is not entirely intuitive. How do you go back to a previous state of the entire project at the point of a single commit?
There are no local changes according to Github Desktop....
no changesThe commit that I want to go back to is the 3rd commit down on the left. I figure that (according to their instructions) I would revert the two latest commits and I'd be back where I want to be.
a simple plan
But Github protets and claims there are changes.....
only there aren't any changes
But, there aren't any changes.
WTF Github?
I'm not worried about the code......
I'm just irritated that a versioning system so widely used would be so poorly designed.