{"id":365,"date":"2020-11-16T13:56:11","date_gmt":"2020-11-16T13:56:11","guid":{"rendered":"http:\/\/mohammedlakkadshaw.com\/blog\/?p=365"},"modified":"2020-11-16T13:56:11","modified_gmt":"2020-11-16T13:56:11","slug":"how-to-setup-kdiff3-as-a-git-mergetool-in-wsl","status":"publish","type":"post","link":"https:\/\/mohammedlakkadshaw.com\/blog\/how-to-setup-kdiff3-as-a-git-mergetool-in-wsl.html","title":{"rendered":"How to setup kdiff3 as a git mergetool in WSL"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I have been developing in windows WSL recently and I encountered a problem, when in case of a merge conflict how to use a good GUI mergetool.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I really like the kdiff3 on windows, so here is how you can set it up as a default mergetool in Git<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Download and install the latest version of kdiff3 for windows fromhere http:\/\/kdiff3.sourceforge.net\/<\/li><li>Setup kdiff3 in your path, so that WSL can easily find it<ol><li>Click on start button and search env and open &#8220;Edit the system environment variables&#8221;<\/li><\/ol><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image.png\" alt=\"\" class=\"wp-image-366\" width=\"674\" height=\"582\" srcset=\"https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image.png 786w, https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-300x259.png 300w, https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-768x663.png 768w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2. Then click on Enviroment Variables button<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"414\" height=\"468\" src=\"https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-1.png\" alt=\"\" class=\"wp-image-367\" srcset=\"https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-1.png 414w, https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-1-265x300.png 265w\" sizes=\"auto, (max-width: 414px) 100vw, 414px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3. Then select Path and click Edit button<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"584\" src=\"https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-2.png\" alt=\"\" class=\"wp-image-368\" srcset=\"https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-2.png 614w, https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-2-300x285.png 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">4. Then click New and Add the Path where KDiff3 is installed under Program Files<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"526\" height=\"503\" src=\"https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-3.png\" alt=\"\" class=\"wp-image-369\" srcset=\"https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-3.png 526w, https:\/\/mohammedlakkadshaw.com\/blog\/wp-content\/uploads\/2020\/11\/image-3-300x287.png 300w\" sizes=\"auto, (max-width: 526px) 100vw, 526px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Setting up default merge tool in Git<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open WSL terminal and type in the following commands to set kdiff3 as the default <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global merge.tool kdiff3\ngit config --global mergetool.kdiff3.path \"\/mnt\/c\/Program Files\/KDiff3\/kdiff3.exe\"\ngit config --global mergetool.kdiff3.trustExitCode false\n\ngit config --global diff.guitool kdiff3\ngit config --global difftool.kdiff3.path \"\/mnt\/c\/Program Files\/KDiff3\/kdiff3.exe\"\ngit config --global difftool.kdiff3.trustExitCode false\ngit config --global difftool.kdiff3.cmd 'kdiff3.exe \\\"`wslpath -w $LOCAL`\\\" \\\"`wslpath -w $REMOTE`\\\"'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it! Now if you run <code>git mergetool<\/code> command, kidff3 will open up as your default merge tool.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been developing in windows WSL recently and I encountered a problem, when in case of a merge conflict how to use a good GUI mergetool. I really like the kdiff3 on windows, so here is how you can set it up as a default mergetool in Git Download and install the latest version [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-365","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts\/365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/comments?post=365"}],"version-history":[{"count":0,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts\/365\/revisions"}],"wp:attachment":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/media?parent=365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/categories?post=365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/tags?post=365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}