I sent on my GitHub two obligations commits. https://zapodaj.net/2ba0d2207c251.png.html However, I made a small mistake and I would like to restore the draft 0.0.2.4 project version. I want to withdraw the last two commits from GitHub. I am fighting with this about 3 hours and I have no idea how to do it.
Asked
Active
Viewed 101 times
1
-
Possible duplicate of [How to revert Git repository to a previous commit?](https://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit) – phd Sep 09 '17 at 10:08
1 Answers
1
If you don't need those commits, simply reset your master HEAD and force push
git checkout master
git reset --hard @~2
git push --force
Make sure you are the only one working on that repo though (before force pushing).
And make sure you don't have any work in progress (before an hard reset)
You can also make a temporary branch before the hard reset (git branch tmp
), that way you keep track of those faulty commits content if you need them.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
@aedgftsdgh I will assume you follow the answer above: your current commit is the right one, but with the wrong commit message. A `git commit --amend` will allow you to change the commit message locally (first line 0.0.2.4, second line, the rest of the description). Then `git push --force` again. – VonC Sep 09 '17 at 03:04