0

I know there are many articles and questions covering this topic, but none of them seem to be offering a solution to my issue. I basically created a new branch from develop, and then I checkout into it, and then I ran git merge origin develop in order to merge the develop into my new branch, but I got this error: Error

I clicked on the source control button from the left sidebar, and this is what I get: enter image description here

If I click on Merge Changes dropdown, I see two files - package-lock.json and package.json. When I click on either one of them, the right side of the vscode gets split into two, and it shows yours and theirs screens, and beneath result, and there's a 1 conflicts remaining text too, and there's also a Accept Merge button, but when I click it, a window pops up asking me if I want to continue with conflicts.

This morning I screwed up the project of the company, and I still feel really bad about it, but I still don't get how do I fix this? They told me I have to resolve the merge conflict, but I don't know how. I've never done this before. I am looking at the two split screens, and I don't see any lines emphasized in red for me to "resolve". There are just lines emphasized in green.

Isn't there a button I can just click, and be shown the "conflict"? How do I know how to resolve, and how do I resolve it?

happy_story
  • 1
  • 1
  • 7
  • 17
  • there a lot of books and websites/videos that tell you how to handle merge conflicts, one simple way open the file with conflicts and edit it so the conflict markers are gone and the file is working/compiling – rioV8 Aug 09 '22 at 15:49
  • 1
    Rule for beginners: Never let a computer resolve merge conflicts automatically. Rule for advanced users: *rarely* let a computer resolve merge conflicts automatically. :-) Unfortunately, [there's no Royal Road here](https://idioms.thefreedictionary.com/royal+road+to). You just have to understand the issues and think about the problem. [Relatedly, yarn lock files should be committed](https://stackoverflow.com/q/39990017/1256452) but *never let Git merge them* as they are to be computed *by* yarn. Resolve the *inputs*, and re-compute the lock file (and verify that it's correct). – torek Aug 09 '22 at 18:57
  • 1
    The link above is for yarn but package-lock.json files should probably be treated similarly. – torek Aug 09 '22 at 18:58
  • @torek Thanks for the advice. I've already fixed it. There were some conflicts remaining that weren't marked in red. I had to manually review all the files to get rid of them. – happy_story Aug 10 '22 at 13:03

1 Answers1

2

As torek mentioned, you should only resolve the conflicts manually for package.json and let package-lock.json be regenerated. Resolving conflicts can be simple or difficult, it depends.

However what really helps is to use a proper 3-way merge tool that shows three sources: common base version, merge from version and merge to version, along with a destination output where you resolve conflicts into.

Kdiff3 is a merge tool that supports this, and if you use my git-resolve-conflict-using-kdiff3 script it will automatically launch kdiff3 with all the appropriate versions.

hlovdal
  • 26,565
  • 10
  • 94
  • 165