How to use Visual Studio as your external merge tool – 106

Hmm, I wonder what could possibly be my tip for the day after yesterday’s tip!

In yesterday’s scenario, you saw how to use VS to do a diff. In today’s tip, you’ll see how to do a merge when you do `git merge branch-name` and get into a merge conflict. Hopefully you’re feeling a bit more confident when you see merge conflict now. (Yeah that’s actually my hope for myself.)

First, go to Team Explorer – Settings – Git – Global Settings and for Merge tool, click Use Visual Studio

Merge Tool: Use Visual Studio

Suppose you have a file in one branch (mine is called readme) that contains a conflict. When you go to merge into master, you’ll see a merge conflict.

You can open the mergetool by running

$ git mergetool

git mergetool prompting to open in VS

Follow the instructions and hit Enter.

Now the VS Merge tool appears

VS merge tool

Clean up your readme.txt in the bottom part of the screen (or however you want to use the merge tool).

Now we’ll see that we have changes in our working directory.

need to do git add to stage changes from merge

You can do a `git add readme.txt` to add this file to staging.

file added to staging

And now we commit our merge commit via `git commit -m “merged readme”`

committing our merge commit

and the `git log` confirms our merge.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s