Home > Software design >  Undo Revert Commit in Azure-DevOps
Undo Revert Commit in Azure-DevOps

Time:11-20

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.

CodePudding user response:

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

  • Related