Dinesh
Dinesh

Reputation: 109

Conflict prevents automatic merging

What is the best way to resolve the automatic merging conflicts.

This is the scenario

  1. I created a Local Branch from the master.
  2. Do some implementation and commit changes.
  3. Addressed the review comments by reviews and then amend previous commit.
  4. After complete the PR(automatically merging to master).
  5. After completing there were some review comments that I needed to address.
  6. Changed the code accordingly and then amend to previous.
  7. Since previous PR is already completed, I had to create a new PR for this.
  8. Once I create the new PR, now I am getting " conflict prevents automatic merging"

I think the issue is since I amend the last commit to the previous, it identify as one commit. My master has commit which I made earlier.

Could someone tell me what is the best approach to resolve this.

Upvotes: 0

Views: 2115

Answers (2)

Ahmad Pujianto
Ahmad Pujianto

Reputation: 359

If you using Visual Studio 2022, then follow these steps :

  1. Open window 'git changes'.

  2. On list branch, found your destination branch (in your case Master, in my case dev). Right click and select 'merge into current branch' Viola, you will see list of file you commited separated in two groups. One group is file that has no-conflict (staged) and the other is the one that has conflict (unstaged).

  3. In my case I only need to stage all file that unstaged (hence in conflict). Depending on your condition, maybe you need to fix before staged all unstaged file.

  4. If all unstaged file hasbeen staged or deleted, then Sync.

  5. Problem should be fixed.

Upvotes: 1

user11103114
user11103114

Reputation:

You should probably create a new commit that addresses the findings from the second review and a new PR for it. Both commits will remain in the git history.

Other options include:

  • force pushing changes to master (not recommended and probably forbidden)
  • rebasing your current PR onto master (this would create two commits with similar messages)

For the future I'd recommend not amending commits after other develpoers have had access to them (after pushing/merging them onto shared branches, ...) because this can cause such issues.
Also reviews should generally be done before merging things into a master branch.

Upvotes: 1

Related Questions