Git Merge In Visual Studio

I recently switched job roles and as always, with moving to a new company, you get a new machine that just doesn't feel right until you've installed and set up every application that you need to get developing.

Probably one of the most crucial aspects of this for me is setting up Merge for Git. I've played around with a couple of merge tools since I started using Git, first KDiff and then Beyond Compare and I have to say that neither have come remotely close to the built in Visual Studio Merge tool I've used in the past working with TFS.

The most frustrating thing I found moving to Git was this poor merging and at the early stage it nearly put me off completely. That was, until a colleague mentioned that it was possible to use the built in VS merge tool with git. 

This was a revelation, but how?

It's quite simple actually, you just need to edit your git config that can be found at 
'‪C:\Users\<USERNAME>\.gitconfig'

Then copy in the following settings:

[user]
name = <gitusername>
email = <yourname@youremail.com>

[diff]
    tool = vsdiffmerge
[difftool]
      prompt = false
[difftool "vsdiffmerge"]
      cmd = '"C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe"' "$LOCAL" "$REMOTE" //t
      keepbackup = false
      trustexitcode = true

[merge]
      tool = vsdiffmerge
[mergetool]
      prompt = false
[mergetool "vsdiffmerge"]
      cmd = '"C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe"' "$REMOTE" "$LOCAL" "$BASE" "$MERGED" //m
      keepbackup = false
      trustexitcode = true

It's useful to note I tend to close my project before I do any merging, especially if the .csproj file is conflicted, trying to merge this with the project open will cause Visual Studio to crash. 

Git should fire up a new instance allowing you to merge the necessary files once the merge is in progress.

1 comment:

  1. Everything is great and set up in exceptionally brilliant way. I additionally keep up my room and I got numerous thoughts from your blog and visit https://www.aussiessayservices.com/auedubirdie-review/ website for useful task. The LCD stand include four stars its magnificence. I might want to plan or purchase same stuff. Keep it up!

    ReplyDelete