Reader small image

You're reading from  Git for Programmers

Product typeBook
Published inJun 2021
PublisherPackt
ISBN-139781801075732
Edition1st Edition
Right arrow
Author (1)
Jesse Liberty
Jesse Liberty
author image
Jesse Liberty

Jesse Liberty is a full-time hands-on programmer, specializing in C#, git and .NET MAUI. He hosts the popular Yet Another Podcast and is the author of more than a dozen best-selling programming books. Liberty is a Certified Xamarin Developer, a Xamarin MVP and a Microsoft MVP. He was a Technical Evangelist for Microsoft, Distinguished Software Engineer at AT&T; Software Architect for PBS and Vice President of Information Technology at Citibank, and he was on the teaching staff at Brandeis University. Jesse is a recognized expert and has spoken at conferences world-wide.
Read more about Jesse Liberty

Right arrow

Merge conflicts

Let's turn to the command line and do a pull as our branch has diverged from the origin. When we do, we're told that there is a merge conflict in Program.cs and that the merge has failed. Git tells you to fix the conflicts and then commit the result. This is unusual, to get a merge conflict on a pull, but as you can see, it does happen. Let's handle this conflict and then set up a more typical situation:

Figure 4.16: A merge conflict

There are a few ways to handle any merge, but the easiest is to use a merge tool. I use KDiff3 (https://sourceforge.net/projects/kdiff3/). Since I use this a lot, I have put it into my config file:

git config --edit --global 

Figure 4.17: Reviewing the configuration file

This sets up KDiff3 as my merge tool and tells Git where to find it. One of the things I like most about KDiff is that it will often fix the problem for you.

To invoke it, all I need to write is:

git mergetool
...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Git for Programmers
Published in: Jun 2021Publisher: PacktISBN-13: 9781801075732

Author (1)

author image
Jesse Liberty

Jesse Liberty is a full-time hands-on programmer, specializing in C#, git and .NET MAUI. He hosts the popular Yet Another Podcast and is the author of more than a dozen best-selling programming books. Liberty is a Certified Xamarin Developer, a Xamarin MVP and a Microsoft MVP. He was a Technical Evangelist for Microsoft, Distinguished Software Engineer at AT&T; Software Architect for PBS and Vice President of Information Technology at Citibank, and he was on the teaching staff at Brandeis University. Jesse is a recognized expert and has spoken at conferences world-wide.
Read more about Jesse Liberty