Thursday, January 24, 2013

GIT: reverting a second commit of the push from central repository

Have you ever come across the issue, where you have pushed your code to a central repository but unknowingly old commit also has been pushed which is not required any more.

In general, If you want to revert a last commit:

$ git revert d768b8d6a709ba5524e2cf68915d718b9e9ae0bf

In your last push, you have pushed two commits and imagine second commit now you want to roll back,

$ git revert a768b8d6a709ba5524e2cf68915d718b9e9ae0be

fatal: Commit 137ea95 is a merge but no -m option was given.

You will come across above issue,

To resolve that, we need use -m option with order of a commit. Like below,

$ git revert a768b8d6a709ba5524e2cf68915d718b9e9ae0be  - m 2

This will revert second commit which you have made.


No comments:

Post a Comment