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:
- open external non-repo file in vim usual way
- do
:vsp newvertically split new (blank) window :cdworking directory of git repository:read !git show master~2:myfileread contents of myfile 2 commits agosetf yourfiletypeheresyntax highlighting (optional):diffthisin 1 window, switch other window , run:diffthisagain, , have diff
Comments
Post a Comment