version control - Can git do a diff between a repo file and an external (non-repo) file? -


i need diff between version of myfile in master~2, , copy of myfile exists outside repository (say d:\folder\myfile).

the wording in git-diff under --no-index says:

git diff --no-index [--options] [--] […]

this form compare given 2 paths on filesystem. can omit --no-index option when running command in working tree controlled git , at least 1 of paths points outside working tree

the wording "at least one" seems imply comparison can done between 1 repo file , 1 non-repo file, in practice:

$ git diff master~2:myfile d:/folder/myfile   error: not access: 'master~2:myfile'  $ git diff master~2:myfile -- d:/folder/myfile   fatal: d:/folder/myfile: 'd:/folder/myfile' outside repository    $ git diff --no-index master~2:myfile -- d:/folder/myfile   usage: git diff --no-index <path> <path> 

what easiest way achieve comparison?

without using git-diff, found indirect way of achieving - method given in this blog post, using external file original "current file", , making sure have repo directory current-directory before doing git show.

the steps involved are:

  1. open external non-repo file in vim usual way
  2. do :vsp new vertically split new (blank) window
  3. :cd working directory of git repository
  4. :read !git show master~2:myfile read contents of myfile 2 commits ago
  5. setf yourfiletypehere syntax highlighting (optional)
  6. :diffthis in 1 window, switch other window , run :diffthis again, , have diff

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -