9

I merged a pull request into our dev branch, but there needs to be an additional change to one of the files. I want to revert the pull request, and then add the changes to the feature branch, but when I use the revert button in Azure Devops in says:

Encountered conflicts when reverting commit '8a750f'. This operation needs to be performed locally.

Very uninformative, and nothing to point out what or where the error is.

My first question is: is a revert of the original feature branch, add the new changes here, and then merge them again in Dev, using a new pull request the best way to add the new changes? Or should I add the new changes into a new branch and push that branch into Dev? My main concern is then how do I push these two feature branches (the one already merged with Dev and the new one) onto further branches, like Test and Master?

Second question is about the error message: What does it mean and how can I check the conflicts? I work with Visual Studio 2019, and .Net Core 2.2.

CMorgan
  • 645
  • 2
  • 11
  • 33
  • Assuming `dev` is you integration branch, then yes do it on a topic/feature branch. And doing it locally gives you far more options to diagnose problems. – Richard Mar 16 '20 at 10:41
  • Do you know exactly how [git revert works](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert)? It does not undo the previous commit, it adds a new commit that cancells the changes from the previous one. Are you sure that it's what you actually want to do? See also [this question about undoing a merge](https://stackoverflow.com/questions/2389361/undo-a-git-merge-that-hasnt-been-pushed-yet). – natka_m Mar 16 '20 at 11:40
  • I cannot do anything directly on the Dev branch, because of constraints. So what I had in mind was: revert previous pull request, pull the dev branch locally, add new changes to the feature branch that was merged previously, push the edited branch, and merge in Dev with a pull request. – CMorgan Mar 16 '20 at 11:51
  • @Richard So, start a new branch and push that to dev, on top of the earlier pull request? – CMorgan Mar 16 '20 at 12:30
  • 1
    That is correct. Where you have to use PRs then it will always be the approach – Richard Mar 16 '20 at 13:13
  • May I know how's the status of this after the weekend? Do you has any puzzle with below explanation? Don't hesitate to share you comment below if you still has any puzzle with that. – Mengdi Liang Mar 23 '20 at 01:02

1 Answers1

2

Is a revert of the original feature branch, add the new changes here, and then merge them again in Dev, using a new pull request the best way to add the new changes?

Based on my own, strongly agree with the opinion that above comments mentioned. As what you want to achieve, I don't think use revert is a good idea. Because it actually will make a mess to your repository at last.

As you said in comment, after revert, you have to re-do the all changes to feature branch which includes the one was merged previously but cancelled later. Its advantages is it can assure the integrity of your repositories history. But I don't think it would be a best way in your scenario.


To more great for explanation, originally, the pull request was merged feature branch into dev branch, then you found you need add another changes to one of file.

So, why not direct make this new change into feature branch, then do push it into dev branch again?

As what you concerned, if you create a new branch to make apply your new change, it will cause trouble when they need merged onto further branch, because you must keep them sync with each other, or it will cause conflict easily.


Another, if create a new branch is the choice you have to make. You can create this new branch based on feature branch. After the new change applied into the file, merge the new branch into feature branch via pull request. Then merge the feature branch into dev branch.

At this time, the new branch can be delete since all of changes are all sync back to feature branch. Also, you can continue work on feature branch later.

What does it mean and how can I check the conflicts?

There has one other thread explained it very detailed. You can check that.

To solve that, you can try with below script:

# Unstage conflicts  
git reset HEAD ./  

# Unstage deletions and reset everything back to master
git checkout -- ./ 

# Cancel the pending revert operation
git revert --abort 

$ git checkout 8a750f

# Make use of tag feature, it can help for this kind of issue in the future.
$ git tag mark

$ git push origin mark
Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35
  • 1
    Thank you for the detailed explanation! I solved it by not reverting but adding the new changes directly to the feature branch. It worked, it's now in the master branch. – CMorgan Mar 30 '20 at 16:28