简体   繁体   中英

Resolve merge conflict for single file in Git

I have cloned branch from develop branch and made some changes on it then raised pull request but in BitBucket I have the below error

Conflict: Modified on Source, Modified on Target This file is in a conflicted state. You will need to resolve the conflict manually before you can merge this pull request

My branch name - social cloned branch - develop

I could see many forums but could not get resolve the issue. I would want to resolve one single file. Is there any way to do in git?

The error tells you that you need to resolve the merge conflict manually. This means that you need to open the file with a text editor and search for the text of

<<<<<<<

which is the start of a conflict, unless this text was genuinely written into your file. The merge conflict ends with

>>>>>>>

so, between the two you have your conflict. The conflict means that the file you had and the file you have downloaded differ in the conflict. Between the two version there is a separation of

=======

Look at both versions and decide which is correct. If neither, then copy-paste the one which is closer to being correct and fix it.

This is probably happening because there has been changes in the develop branch since the time you cloned the repo. So git history is something like this:

A - D1             (develop branch)
  \- Y1 - Y2       (your branch)

A is the commit where you checked out your branch and added commits Y1 and Y2. In the meanwhile, D1 was added on the develop branch. And basically D1 introduced changes that conflict with your changes in Y1 and Y2. There are two ways to fix this: 1. Merge the latest develop to your current branch and manually resolve the conflicts. 2. Rebase the latest develop on your current branch and manually resolve the conflicts. The rebase would result in a nicer linear history without any merge commits.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM