{"id":27310,"date":"2017-02-09T15:54:35","date_gmt":"2017-02-09T13:54:35","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=27310"},"modified":"2017-02-10T00:10:11","modified_gmt":"2017-02-09T22:10:11","slug":"use-vimdiff-as-git-mergetool","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/09\/use-vimdiff-as-git-mergetool\/","title":{"rendered":"Use vimdiff as git mergetool"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>Ruslan Osipov has a very handy tutorial on how to <a href=\"http:\/\/www.rosipov.com\/blog\/use-vimdiff-as-git-mergetool\/\">setup Vim text editor as git merge tool<\/a>, for resolving git conflicts.<\/p>\n<p>Basically, run the following commands to tell git to use Vim as a merge tool (don&#8217;t forget the <em>&#8211;global<\/em> flag if you want it for all your projects, not just the current one):<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\ngit config merge.tool vimdiff\r\ngit config merge.conflictstyle diff3\r\ngit config mergetool.prompt false\r\n<\/pre>\n<p>With that, running &#8220;<em>git mergetool<\/em>&#8221; after a conflict was reported, will result in something like this:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/three-way-merge-with-vimdiff.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"27311\" data-permalink=\"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/09\/use-vimdiff-as-git-mergetool\/three-way-merge-with-vimdiff\/\" data-orig-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/three-way-merge-with-vimdiff.png?fit=967%2C500&amp;ssl=1\" data-orig-size=\"967,500\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"three way merge with vimdiff\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/three-way-merge-with-vimdiff.png?fit=660%2C341&amp;ssl=1\" class=\"aligncenter size-medium wp-image-27311\" src=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/three-way-merge-with-vimdiff-500x259.png?resize=500%2C259&#038;ssl=1\" alt=\"\" width=\"500\" height=\"259\" srcset=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/three-way-merge-with-vimdiff.png?resize=500%2C259&amp;ssl=1 500w, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/three-way-merge-with-vimdiff.png?resize=768%2C397&amp;ssl=1 768w, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/three-way-merge-with-vimdiff.png?w=967&amp;ssl=1 967w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>The three way split window will show local version (<em>&#8211;ours<\/em>) on the left, the remote version (<em>&#8211;theirs<\/em>) on the right, and the base version with the conflict in the middle. \u00a0You can then get changes from one window into another using the following Vim diffget commands:<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\n:diffg RE  &quot; get from REMOTE\r\n:diffg BA  &quot; get from BASE\r\n:diffg LO  &quot; get from LOCAL\r\n<\/pre>\n<p>Awesomeness!<\/p>\n<p>Check a few of Ruslan&#8217;s other <a href=\"http:\/\/www.rosipov.com\/blog\/categories\/vim\/\">vim-related articles<\/a>.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Ruslan Osipov has a very handy tutorial on how to setup Vim text editor as git merge tool, for resolving git conflicts. Basically, run the following commands to tell git to use Vim as a merge tool (don&#8217;t forget the &#8211;global flag if you want it for all your projects, not just the current one): &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/09\/use-vimdiff-as-git-mergetool\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Use vimdiff as git mergetool<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Use vimdiff as git mergetool #Vim #git #WebDev #programming","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62],"tags":[2265,2297,1588,3094,1330],"keyring_services":[],"class_list":["post-27310","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-git","tag-text-editors","tag-version-control","tag-vim","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":27460,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/03\/26\/composer-git-hooks-manage-git-hooks-in-your-composer-config\/","url_meta":{"origin":27310,"position":0},"title":"composer-git-hooks &#8211; manage git hooks in your composer config","author":"Leonid Mamchenkov","date":"March 26, 2017","format":false,"excerpt":"composer-git-hooks looks awesome! \u00a0From the project page description: Manage git hooks easily in your composer configuration. This package makes it easy to implement a consistent project-wide usage of git hooks. Specifying hooks in the composer file makes them available for every member of the project team. This provides a consistent\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":16526,"url":"https:\/\/mamchenkov.net\/wordpress\/2012\/07\/20\/wp-config-php-and-git\/","url_meta":{"origin":27310,"position":1},"title":"wp-config.php and git","author":"Leonid Mamchenkov","date":"July 20, 2012","format":false,"excerpt":"If you are storing your WordPress changes in git and then deploy the project between different machines (local, test server, production environment, etc), then you are probably familiar with a problem of wp-config.php file. \u00a0WordPress uses it for things like database credentials, which vary from machine to machine. \u00a0But you\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":29058,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/12\/10\/git-merge-vs-git-rebase\/","url_meta":{"origin":27310,"position":2},"title":"git merge vs. git rebase","author":"Leonid Mamchenkov","date":"December 10, 2018","format":false,"excerpt":"There's a lot of confusion between git merge and git rebase even among seasoned users of git.\u00a0 \"An Introduction to Git Merge and Git Rebase: What They Do and When to Use Them\" is a great article explaining the pros and cons of each, and when and why using each\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/12\/git-merge-rebase.jpeg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/12\/git-merge-rebase.jpeg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/12\/git-merge-rebase.jpeg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":27398,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/03\/08\/how-to-use-git-to-manage-your-user-configuration-files\/","url_meta":{"origin":27310,"position":3},"title":"How To Use Git to Manage your User Configuration Files","author":"Leonid Mamchenkov","date":"March 8, 2017","format":false,"excerpt":"There is probably a gadzillion different ways that you can manage and synchronize you configuration files (aka dotfiles) between different Linux\/UNIX boxes - anything from custom symlink scripts, all the way to configuration management tools like Puppet and Ansible. \u00a0Here are a few options to look at if you are\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26154,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/06\/03\/deploying-with-git\/","url_meta":{"origin":27310,"position":4},"title":"Deploying with git","author":"Leonid Mamchenkov","date":"June 3, 2016","format":false,"excerpt":"Git is an excellent version control, but it's more than just that. \u00a0A lot of people use it to deploy their projects as well. \u00a0Most suggestions (for example, this tutorial from Digital\u00a0Ocean) around the web employ the post-commit (or other) hooks to push the code to a remote server. \u00a0While\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26189,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/06\/15\/git-2-9\/","url_meta":{"origin":27310,"position":5},"title":"Git 2.9","author":"Leonid Mamchenkov","date":"June 15, 2016","format":false,"excerpt":"Git 2.9 has been released a few days, bringing in some very useful functionality, such as showing renamed files in git diff and git log, forbidding the merge of two branches that have no common ancestors, configurable path to hooks, and more. \u00a0All are welcome changes, making the life of\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=27310"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27310\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=27310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=27310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=27310"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=27310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}