【发布时间】:2018-01-05 14:54:57
【问题描述】:
是否可以通过 ssh 在两台远程服务器上使用命令 git diff --no-index。
我想在非存储库上使用命令 git diff 的输出。两个远程 ssh 目录之间。
【问题讨论】:
-
在非存储库上是不可能的,但在两个 repo 之间可能是
是否可以通过 ssh 在两台远程服务器上使用命令 git diff --no-index。
我想在非存储库上使用命令 git diff 的输出。两个远程 ssh 目录之间。
【问题讨论】:
我从来没有跨服务器桥接 diff 命令,但实际上......你只会使用diff。 git diff 使用系统指定的任何diff 工具来比较不同的版本,并且由于--no-index 允许您在非版本控制的文件之间进行比较,所以diff 是您的最佳选择。
【讨论】:
你可以试试这个:
# Get the working tree from repo 1:
git archive --format=zip --remote=ssh://<user>@<host>/repo1/<repo1 name> <tag or HEAD> > archive1.zip
# Get the working tree from repo 2:
git archive --format=zip --remote=ssh://<user>@<host>/repo2/<repo2 name> <tag or HEAD> > archive2.zip
mkdir tmpdir tmpdir2
(cd tmpdir; git init .)
# Unzip archive1 into tmpdir, make a temporary git repo out of it:
(cd tmpdir; unzip ../archive1.zip ; git add .; git commit -a -m "archive1")
# Move the .git directory to tmpdir2:
mv tmpdir/.git tmpdir2
# Unzip archive2 into tmpdir2, and compare:
(cd tmpdir2; unzip ../archive2.zip ; git diff ) > git-diff.txt
# Cleanup:
rm -rf tmpdir tmpdir2 archive1.zip archive2.zip
【讨论】: