1

I had merged a development branch into my ticket branch for which a commit Merge branch 'develop/branchname' into 'ticketbranch' was created. There were some confusions, so I had to revert this commit in Azure DevOps using the revert option. For this, 2 commits are created - first Revert Merge branch 'develop/branchname' into 'ticketbranch'(PR #123) and then Merged PR #123 Revert Merge branch 'develop/branchname' into 'ticketbranch'(PR #123). In Dev-Ops the commits are shown in the following order:

    Commits                                                                      PR
    --------                                                                    ----
(1) Merged PR #123 Revert Merge branch 'develop/branchname' into 'ticketbranch'  123
(2) Revert Merge branch 'develop/branchname' into 'ticketbranch'                 123
(3) Merge branch 'develop/branchname' into 'ticketbranch'
.....
....

Now, because some clarity in my previous doubts, I want to re-revert my last commit My question is which commit should I revert - 1 or 2? Note that both shows the same file changes.

1 Answer 1

1

When you use git revert you specify the commit that you want to undo the changes of. Git does that by creating a new revert commit.

So if you want to undo your last commit changes, which happens to be the revert commit you will run git revert Merged PR #123 Revert Merge branch 'develop/branchname' into 'ticketbranch' (make sure to specify the SHA of the commit and not the title)

You can also do git revert HEAD and it will undo the commit changes

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply stackoverflow.com/users/11485794/nadar. Also, one more thing, we need to provide the parent no while writing the revert commit(in case of a merge revert merge commit), this link describes it clearly tilns.herokuapp.com/posts/962b8d3fc2-reverting-a-merge-commit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.