Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "unrevert" a previously reverted commit?

Tags:

git

git-revert

Imagine the following scenario:

Code that shouldn't have been merged to the integration branch needs to be reverted. However, you can't just reset, since other commits have happened since then. Further, you may want to re-apply that commit at a later time.

It's easy enough to use git revert to apply a reverse commit. However, what happens when we want to commit that change (from a feature branch, for instance)? Do you just re-merge the branch? Will that work, since technically the code has already been merged?

What do you do when you are finally ready to accept that merge?

like image 485
Erik Funkenbusch Avatar asked May 26 '17 18:05

Erik Funkenbusch


People also ask

Can you revert a reverted commit?

You can only reset to a previous commit and ignore the local changes, or revert the changes.

How do I revoke a previous commit?

The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.

How do I undo a git rollback?

To undo changes associated with a specific commit, developers should use the git revert command. To undo every change that has happened since a given commit occurred, use git reset.


1 Answers

Just revert the revert commit.

git revert HASH_OF_REVERT_COMMIT
like image 106
Manuel Schmidt Avatar answered Oct 13 '22 23:10

Manuel Schmidt