33

So I have a develop branch and topic branch. I'm using the default Terminal in Window's VS Code. While in the topic branch, I did git merge develop since I just got latest on develop branch. Now there's a simple merge conflict in one file. In VS Code, I resolved the conflict. On the code page, there's no more conflicts that you can Accept Incoming or Accept Current, but when I try to stage the file on the Source Control panel on the left, it shows a warning popup saying Are you sure you want to stage with merge conflicts?

Is this normal? it seems like VS Code doesn't think I resolved the conflict even tho I just did, and there's no more conflict in the file. Or is there something I'm missing Git/VS Code-wise?

midnightnoir
  • 671
  • 2
  • 9
  • 16

3 Answers3

17

It is an normal behavior. Usually we will get the merge conflicts when we have changes changes in same line of source and destination files of merging.

In your case, you have resolved your conflicts in your file(i mean vs code) but it is not updated to git. So after adding Accept Incoming or Accept Current you have to do below steps,

  1. git add <conflicts resolved files>
  2. git commit -m "merge conflict resolved message"
  3. git push
saravana va
  • 1,081
  • 1
  • 13
  • 17
11

In VSCode when you have conflicts in multiple files, they're shown in the git panel and you can open files one by one and resolve them.

When you resolve the conflicts in a file, you should save the file then click the + button of that file (shown in the image bellow).

Stage resolved file

This will result in staging the file. If you click this button and there's unresolved conflicts in that file, you'll get this message:

Are you sure you want to stage with merge conflicts?

Now if you resolve conflicts of all files and click on the + button that is above all files (to stage all files with conflict) (Shown in the image bellow), it'll still give you the same message (Although you've already resolved all conflicts).

stage all files

So I recommend that you click the + of each file individually so that you'll be sure that you resolved all conflicts before staging the file.

Note

I believe this bug is fixed in recent versions of VSCode.

Vahid
  • 6,639
  • 5
  • 37
  • 61
  • I can't find the MERGE CHANGES section in my source control panel ! Am I missing something ? – ngCoder Apr 24 '19 at 08:49
  • @ngCoder No that section is displayed only when you have conflicts. – Vahid Apr 24 '19 at 10:59
  • Yes I got that but I do have conflicts as my pull failed,still no sign of this section.Some config is missing ? – ngCoder Apr 24 '19 at 11:07
  • This can be done using below command using cmd ````git remote update```` ````git merge origin/Vishal-Develop -X theirs```` ````git commit -m commit -m "New release"```` ````git push --recurse-submodules=check --progress "origin" refs/heads/Vishal-Master```` Please use branch names accordingly – Vishal Sep 09 '19 at 13:34
  • My VSCode wouldn't let me click the + button with "conflicts" but `git add ` worked just fine. – Slate Oct 19 '20 at 09:52
  • @ngCoder make sure that you installed the git extension – Mo0rteza Nov 13 '21 at 08:03
7

In my case, I realized I had Auto Save turned off. I know, it's too silly. But worth checking.

Imran Panjwani
  • 156
  • 2
  • 6