Can we change the 'has_conflicts' value to false of a merge request?

When I request, merge request of a particular project (having state opened), I got the response like this.

[{
“id”: 253,
“iid”: 3,
“project_id”: 6895,
“title”: “Merge to the master branch”,
“description”: null,
“state”: “opened”,
“merged_by”: null,
“merged_at”: null,
“closed_by”: null,
“closed_at”: null,
“target_branch”: “master”,
“source_branch”: “draft”,
“user_notes_count”: 0,
“upvotes”: 0,
“downvotes”: 0,
“assignee”: null,
“author”: {
“id”: 5,
“name”: “xxxxx”,
“username”: “xxx”,
“state”: “active”,
“avatar_url”: “xxxxx”,
“web_url”: “xx”
},
“assignees”: ,
“source_project_id”: 6895,
“target_project_id”: 6895,
“labels”: ,
“work_in_progress”: false,
“milestone”: null,
“merge_when_pipeline_succeeds”: false,
“merge_status”: “cannot_be_merged”,
“sha”: “0a375a86cc753ea3fe78a2fc50c0a1cdf302ab38”,
“merge_commit_sha”: null,
“squash_commit_sha”: null,
“discussion_locked”: null,
“should_remove_source_branch”: null,
“force_remove_source_branch”: null,
“reference”: “!3”,
“references”: {
“short”: “!3”,
“relative”: “!3”,
“full”: “xxx”
},
“web_url”: “xxxx”,
“time_stats”: {
“time_estimate”: 0,
“total_time_spent”: 0,
“human_time_estimate”: null,
“human_total_time_spent”: null
},
“squash”: false,
“task_completion_status”: {
“count”: 0,
“completed_count”: 0
},
“has_conflicts”: true,
“blocking_discussions_resolved”: true
}]

The “has_conflicts” status is true and “merge_status” is “cannot_be_merged”, So I can’t merge the project. How can I solve this issue using API?

These states are based on how git analyzes your code changes.

What likely happened is someone merged in new changes to the branch you are merging to after you had branched from it. And both your change and the other individuals’ changes were touching similar parts of the same file

You will likely need to fix merge conflicts on your local repository with

$ git checkout currentMR

# assuming you’ve added the destination remote as “prod”
$ git remote update


# then run one of the following:

# Cleaner commit history, may have to fix conflicts in multiple commits
$ git rebase prod master

# Single “merge xx/xx from url into branch” but single commit to fix conflicts
$ git pull prod/master

There’s also this blog post from 2016 about the “resolve merge conflicts from the UI”. I haven’t been able to find any Gitlab API reference that does the same thing as that button (because I assume they expect you to resolve them locally using git)

1 Like