{"id":86,"date":"2009-10-09T09:47:14","date_gmt":"2009-10-09T14:47:14","guid":{"rendered":"http:\/\/ebixio.com\/blog\/?p=86"},"modified":"2019-01-23T22:32:55","modified_gmt":"2019-01-24T03:32:55","slug":"git-on-windows","status":"publish","type":"post","link":"http:\/\/ebixio.com\/blog\/2009\/10\/09\/git-on-windows\/","title":{"rendered":"Git on Windows"},"content":{"rendered":"<p>One of the problems with using git on Windows is that it&#8217;s difficult to integrate it with other native (Windows) tools. That&#8217;s because the environment git runs in (cygwin or msysgit) refers to files by their UNIX name, but the Windows tools have no notion of where <code inline=\"on\" lang=\"bash\">\/tmp<\/code> is for example (and that location can be different between cygwin and msysgit).<\/p>\n<p>When doing an interactive rebase, the editor might be asked to edit a file such as <code inline=\"on\" lang=\"bash\">\/cygdrive\/c\/some\/path\/to\/a\/file<\/code>. When doing a diff in git, one or both of the files to be diff&#8217;d might be placed by git in <code inline=\"on\" lang=\"bash\">\/tmp<\/code>. Windows tools don&#8217;t understand such path names.<\/p>\n<p>Fortunately, cygwin ships with a utility called <code inline=\"on\" lang=\"bash\">cygpath<\/code> that can be used to convert between UNIX and Windows paths. Msysgit doesn&#8217;t have this utility, but if cygwin&#8217;s <code inline=\"on\" lang=\"bash\">\/bin<\/code> directory is in your Windows path, msysgit will pick it up and the scripts below will be usable for both cygwin and msysgit.<\/p>\n<p>Here&#8217;s a <code inline=\"on\" lang=\"bash\">GitEditor.sh<\/code> script that can be used as a wrapper around your editor:<\/p>\n\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#!\/bin\/sh\n\n# Author: Gabriel Burca\n#\n# Script arguments:\n# file-to-edit\n\nFILE=`cygpath -w \"${1}\"`\n\"C:\/Program Files\/Vim\/vim72\/gvim.exe\" \"$FILE\"\n<\/pre>\n\nThis <code inline=\"on\" lang=\"bash\">GitExtDiff.sh<\/code> script can be used as a wrapper around your diff tool:\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#!\/bin\/sh\n\n# Author: Gabriel Burca\n#\n# Script arguments:\n# path old-file old-hex old-mode new-file new-hex new-mode\n\n# The old-file path is typically \"\/tmp\/.diff_something\" and windows programs\n# don't know how to get to \"\/tmp\"\n# We use cygpath to convert to something windows programs understand.\n\nOLD_FILE=`cygpath -w \"${2}\"`\nNEW_FILE=`cygpath -w \"${5}\"`\n\"C:\/Program Files\/WinMerge\/WinMergeU.exe\" -e -ub \"$OLD_FILE\" \"$NEW_FILE\"\n<\/pre>\n\nFinally, you'll need to modify <code inline=\"on\" lang=\"bash\">~\/.gitconfig<\/code> to use these scripts by adding something like this to it:\n<pre lang=\"text\">\n  external = \"C:\/Utility\/GitExtDiff.sh\"\n[core]\n  editor = \"C:\/Utility\/GitEditor.sh\"\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>One of the problems with using git on Windows is that it&#8217;s difficult to integrate it with other native (Windows) tools. That&#8217;s because the environment git runs in (cygwin or msysgit) refers to files by their UNIX name, but the Windows tools have no notion of where \/tmp is for example (and that location can [&hellip;]<\/p>\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,"footnotes":""},"categories":[1],"tags":[6,4,7,9,8],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-cygwin","tag-git","tag-msysgit","tag-vim","tag-windows"],"_links":{"self":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":2,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":714,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/86\/revisions\/714"}],"wp:attachment":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}