git diff用于任何存储库之外的自定义2文件? [英] git diff for custom 2 files outside of any repository?

查看:61
本文介绍了git diff用于任何存储库之外的自定义2文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要任何存储库之外的2个文件的 git diff 功能。有办法吗?像 git diff --file1 /path/file1.txt --file2 /path/file2.txt 这样的东西,如果没有,什么是替代解决方案?

I need git diff functionality for 2 files that I have outside of any repository. Is there a way to do it? Something like git diff --file1 /path/file1.txt --file2 /path/file2.txt If not, what may be an alternative solution?

推荐答案

答案恰好在 git diff 文档(尽管我承认很容易错过):

The answer is right in the git diff documentation (though I admit it's easy to miss):


git diff [< options>]-无索引[-]< path> < path>

git diff [<options>] --no-index [--] <path> <path>

    此形式用于比较文件系统上给定的两个路径。在由Git控制的工作树中运行命令时,可以省略-no-index 选项,并且在运行树之外至少有一个路径点
    This form is to compare the given two paths on the filesystem. You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.

您的情况可能属于 -无索引

Your case might fall into the "--no-index is optional" category, but even if it's optional you can still use it, so:

git diff --no-index /path/file1.txt /path/file2.txt

将使用Git的差异。

这篇关于git diff用于任何存储库之外的自定义2文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆