任何存储库之外的自定义 2 文件的 git diff?

标签 git comparison diff git-diff

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

最佳答案

答案就在the git diff documentation (虽然我承认很容易错过):

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

    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.

您的案例可能属于“--no-index is optional”类别,但即使它是可选的,您仍然可以使用它,因此:

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

将使用 Git 的 diff。

关于任何存储库之外的自定义 2 文件的 git diff?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50889139/

相关文章:

linux - 在 git init 上自动添加 Remote

git - 显示所有分支的 git 前后信息,包括远程

git - 如何在 git 中为 berkshelf 设置 Recipe ?

java - 排序/比较不同的标准

git - pull 、 rebase 、推,在一个命令中(或几个)

javascript - 如果一个数组在 JavaScript 中是真值,为什么它不等于真值?

python - Openpyxl 检查空单元格

git - 比较不同分支中相同文件的正确方法

delphi - 如何针对单个基本文件 "diff"多个文件?

python - 根据python中的条件区分两列 Pandas 数据框