简体   繁体   中英

Merged master into branch and resolved conflicts, but still getting merge conflict on bitbucket PR?

I'm trying to merge my branch into master, but I keep getting merge conflicts in bitbucket. Usually, I just pull any updates from master and merge it into my branch, resolve the conflicts, and upload back to bitbucket, but for some reason, it hasn't been working this time. I've tried merging master into my branch and resolving the conflict multiple times with no luck. I even tried copy-pasting the file from master and then adding back in my changes, but Bitbucket keeps showing conflicts either with nothing, or with lines I didn't touch.

in one file I have a conflict on one of my imports

<<<<<<<
=======
import someFile;
>>>>>>>

in another file, I have a conflict on my dependency

<<<<<<<
=======
<dependency>
    someDependency
</dependency>

and in the third file, I have a conflict with some lines of code I haven't touched, but is the same as what's in master

<<<<<<<                               
                         </connection>
    </channel>
=======                                   
                         </connection>
    </channel>
>>>>>>>

The first two look like a merge conflict with nothing? I'm feeling like the only way to resolve this is to start over from a clean branch, is there any way to resolve this without having to do that?

update: Git was still giving me problems even after double checking my code, so if anyone has this issue here's what I did to resolve it. I did git merge master and instead of resolving the conflicts, I just accepted the incoming changes from master, then committed and pushed (without my code). I copied my changes over again, committed, then pushed again and now all the conflicts are resolved (even though the code hasn't changed at all). It's similar to starting over, except I didn't have to re-add all the files that didn't have merge conflicts.

This is a mundane job for every developer. Basically how git works is that if conflicting files have different heads it shows merge conflicts which means if there are changes made to same files which cannot be auto merged then it shows conflict. You can do the following :-

1) Merge master into your branch by using

git merge master

Now you need to open the conflicted file and manually edit it.

2) Use a tool like source tree, tortoise git etc. They give you good side by side view to fix your conflicts and contain inbuilt editor. They also give you capability to push changes from the tool.

3) Make a new branch and redo your changes. I never had to do this because things are usually solved by 1st or 2nd approach.

PS: There is a possibility that your code editor is adding some formatting as you mentioned you have not touched files. So please try different editor once.

Hope it helps !!

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