Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Visual Studio to show merge conflicts under git?

I'm using Visual Studio 2015 Pro and working with a Git repo. Let's say I did a pull or applied stashed changes or did something that causes my branch to become in conflict. For example, in this case I just applied a stash:

enter image description here

As you can see, I have a bunch of changes but Web.config is in conflict. Why is it always the XML files that have the conflicts?

Now, I go into Visual Studio and go to Team Explorer->Changes:

enter image description here

Here, I see my staged changes, but there are zero unstaged changes. I'm wondering why Web.config doesn't show up here so I can resolve the conflicts.

Two things:

  1. I believe if I were to do a Pull using Visual Studio, it would detect the conflicts that then run the merge tool. I haven't tried this yet, but I know it works that way for TFS. However, I'd like to know if I can use git pull from the command line and then use Visual Studio to resolve conflicts.
  2. git config --global merge.tool is already vsdiffmerge so if I were to run git mergetool from the command line, it would then use Visual Studio to merge. However, doing this spawns a whole new instance of Visual Studio which is slow and annoying, and doesn't let me work in the context of the rest of my project.

Anyone have any insight on this one? Thanks!

like image 888
Mike Christensen Avatar asked Sep 01 '16 23:09

Mike Christensen


1 Answers

In Visual Studio Professional 2017 15.7.4 the Changes window seems to display the conflicts.

enter image description here

The setup:

/mnt/c/git/ConsoleApp1>git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   ConsoleApp1/Class1.cs
        modified:   ConsoleApp1/Program.cs

/mnt/c/git/ConsoleApp1>git stash apply
Auto-merging ConsoleApp1/Program.cs
CONFLICT (content): Merge conflict in ConsoleApp1/Program.cs
/mnt/c/git/ConsoleApp1>git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   ConsoleApp1/Class1.cs

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:      ConsoleApp1/Program.cs

/mnt/c/git/ConsoleApp1>

With colours:

enter image description here

like image 135
tymtam Avatar answered Oct 14 '22 15:10

tymtam