{"id":886,"date":"2023-04-27T18:37:11","date_gmt":"2023-04-27T18:37:11","guid":{"rendered":"https:\/\/www.evan.org\/ghg\/?p=886"},"modified":"2023-04-27T18:41:03","modified_gmt":"2023-04-27T18:41:03","slug":"git-merges-are-an-abomination","status":"publish","type":"post","link":"https:\/\/www.evan.org\/ghg\/git\/git-merges-are-an-abomination\/","title":{"rendered":"Git Merges Are An Abomination"},"content":{"rendered":"\n<p>There are some areas in Git that are so unusable that it baffles me. Merging is one. I tried, but Git really took unusability to new heights here. I recommend trying to do a merge with Git to entertain yourself one day. Just don&#8217;t expect to come out of it with a merged file. I think they included merging as a practical joke.<\/p>\n\n\n\n<p>But Git DOES have hooks that let you use other tools! I played with some of them, and for me Perforce won hands down. Perforce is another source control system, but unlike Git, Perforce likes you. And they made some of their tools free!<\/p>\n\n\n\n<p>So download and install them!<\/p>\n\n\n\n<p><a href=\"http:\/\/www.perforce.com\/product\/components\/perforce-visual-merge-and-diff-tools\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/www.perforce.com\/product\/components\/perforce-visual-merge-and-diff-tools<\/a><\/p>\n\n\n\n<p>Then you just need to wire Git up to use Perforce for merge and diff. To do that, run these git config commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global merge.tool p4merge\ngit config --global mergetool.p4merge.path \/Applications\/p4merge.app\/Contents\/Resources\/launchp4merge\ngit config --global mergetool.p4merge.trustExitCode false\ngit config --global mergetool.keepBackup false\n\ngit config --global diff.tool p4merge\ngit config --global difftool.p4merge.path \/Applications\/p4merge.app\/Contents\/Resources\/launchp4merge\ngit config --global difftool.p4merge.trustExitCode fals<\/code><\/pre>\n\n\n\n<p>Those make changes to your ~\/.gitconfig file \u2013 so if you edit that file, you should see these sections:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;mergetool \"p4merge\"]\n   trustExitCode = false\n   path = \/Applications\/p4merge.app\/Contents\/Resources\/launchp4merge\n   &#91;difftool \"p4merge\"]\n   trustExitCode = false\n   path = \/Applications\/p4merge.app\/Contents\/Resources\/launchp4merge\n\n&#91;merge]\n   tool = p4merge\n\n&#91;diff]\ntool = p4merge\n\n&#91;mergetool]\nkeepBackup = false<\/code><\/pre>\n\n\n\n<p>Then when you need to merge files just type the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git mergetool<\/code><\/pre>\n\n\n\n<p>and you&#8217;ll get Perforce&#8217;s merge tool instead of Git&#8217;s merge!<\/p>\n\n\n\n<p>The Perforce download page has a video on how to use their tools. In essence the top has three columns, the original file, the file with your changes, and the file with the other changes you&#8217;re trying to merge in. The bottom has all the changes merged using P4&#8217;s best guess. Just look for the button at the top to go to the next conflict, and edit the code at the bottom to be as desired. Then save, and close the Perforce editor to go to the next conflict!<\/p>\n\n\n\n<p>Want to know what the settings in the configuration file mean and what else you can configure? Look here:<br><a rel=\"noreferrer noopener\" href=\"https:\/\/git-scm.com\/docs\/git-mergetool\" target=\"_blank\">https:\/\/git-scm.com\/docs\/git-mergetool<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git merges: are they a practical joke?<\/p>\n","protected":false},"author":1,"featured_media":887,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[17],"_links":{"self":[{"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/posts\/886"}],"collection":[{"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/comments?post=886"}],"version-history":[{"count":2,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/posts\/886\/revisions"}],"predecessor-version":[{"id":889,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/posts\/886\/revisions\/889"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/media\/887"}],"wp:attachment":[{"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/media?parent=886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/categories?post=886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/tags?post=886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}