Undo a Git commit after push using reverse patch?

Git

Git Problem Overview


I've pushed a commit and I want to revert changes introduced by this commit by applying and committing a reversed patch. How do I do it?

Git Solutions


Solution 1 - Git

Use

git revert HEAD

This will create a patch that reverts the last commit and commit that patch as a new commit.

If you want to revert a specific earlier version, use

git revert <revision>

see also: http://schacon.github.com/git/git-revert.html

Solution 2 - Git

Solution 3 - Git

simply use

for committed file:

git revert <SHA1 ID>

for non-committed file:

git reset --hard HEAD

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDziamidView Question on Stackoverflow
Solution 1 - GitpilifView Answer on Stackoverflow
Solution 2 - GitKris K.View Answer on Stackoverflow
Solution 3 - GitAmitView Answer on Stackoverflow