Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo a Git commit after push using reverse patch?

Tags:

git

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?

like image 506
Dziamid Avatar asked Jun 22 '11 14:06

Dziamid


People also ask

Can we revert merge commit in git?

You can use the Git reset command to undo a merge. Firstly, you need to check for the commit hash (or id) so you can use it to go back to the previous commit. To check for the hash, run git log or git reflog . git reflog is a better option because things are more readable with it.


2 Answers

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

like image 127
pilif Avatar answered Oct 06 '22 02:10

pilif


Sounds like you want to use git-revert.

https://www.kernel.org/pub/software/scm/git/docs/git-revert.html

like image 33
Kris K. Avatar answered Oct 06 '22 01:10

Kris K.