如何使用 git diff 比较两个不在存储库中的远程文件?
How to compare, with git diff, two remote files which are not in a repository?
我可以用 diff
和 ssh
比较两个远程文件:
diff <(ssh machine1 "sudo cat ${FILE}") <(ssh machine2 "sudo cat ${FILE}")
但如果我尝试 git diff
,
git diff --no-index --color-words <(ssh machine1 "sudo cat ${FILE}") <(ssh machine2 "sudo cat ${FILE}")
我获得:
error: /dev/fd/14: unsupported file type
fatal: cannot hash /dev/fd/14
如何使用 git diff
比较不在存储库中的两个远程文件?
==更新==
这道题不是关于用diff
和colordiff
代替git diff
,而是关于用git diff --no-index
到ssh
。
尝试使用
git diff --no-index <(ssh machine1 "sudo cat ${FILE}") <(ssh machine2 "sudo cat ${FILE}")
已找到 here。
由于 forgotten patch 而无法使用进程替换,唯一的选择(因为您想使用 git diff
)是:
ssh machine1 "sudo cat ${FILE}" > temp1
ssh machine2 "sudo cat ${FILE}" > temp2
git diff --no-index temp1 temp2
您可以使用 diff
(它保持类似于 git diff
的格式和颜色)实现相同的效果,它也适用于进程替换
diff -u --color <(ssh machine1 "sudo cat ${FILE}") <(ssh machine2 "sudo cat ${FILE}")
我可以用 diff
和 ssh
比较两个远程文件:
diff <(ssh machine1 "sudo cat ${FILE}") <(ssh machine2 "sudo cat ${FILE}")
但如果我尝试 git diff
,
git diff --no-index --color-words <(ssh machine1 "sudo cat ${FILE}") <(ssh machine2 "sudo cat ${FILE}")
我获得:
error: /dev/fd/14: unsupported file type
fatal: cannot hash /dev/fd/14
如何使用 git diff
比较不在存储库中的两个远程文件?
==更新==
这道题不是关于用diff
和colordiff
代替git diff
,而是关于用git diff --no-index
到ssh
。
尝试使用
git diff --no-index <(ssh machine1 "sudo cat ${FILE}") <(ssh machine2 "sudo cat ${FILE}")
已找到 here。
由于 forgotten patch 而无法使用进程替换,唯一的选择(因为您想使用 git diff
)是:
ssh machine1 "sudo cat ${FILE}" > temp1
ssh machine2 "sudo cat ${FILE}" > temp2
git diff --no-index temp1 temp2
您可以使用 diff
(它保持类似于 git diff
的格式和颜色)实现相同的效果,它也适用于进程替换
diff -u --color <(ssh machine1 "sudo cat ${FILE}") <(ssh machine2 "sudo cat ${FILE}")