【问题标题】:git diff on two remote servers (outside git git --no-index)两台远程服务器上的 git diff(在 git git --no-index 之外)
【发布时间】:2018-01-05 14:54:57
【问题描述】:

是否可以通过 ssh 在两台远程服务器上使用命令 git diff --no-index。

我想在非存储库上使用命令 git diff 的输出。两个远程 ssh 目录之间。

【问题讨论】:

  • 在非存储库上是不可能的,但在两个 repo 之间可能是

标签: linux git bash ssh


【解决方案1】:

我从来没有跨服务器桥接 diff 命令,但实际上......你只会使用diffgit diff 使用系统指定的任何diff 工具来比较不同的版本,并且由于--no-index 允许您在非版本控制的文件之间进行比较,所以diff 是您的最佳选择。

【讨论】:

  • 是的,但我希望使用 git diff,因为我想使用这个库 diff2html.xyz 需要来自 git diff 的输出
  • 听起来你需要符合图书馆的要求。
【解决方案2】:

你可以试试这个:

# 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

【讨论】:

    猜你喜欢
    • 2016-08-11
    • 2023-03-31
    • 2021-02-08
    • 2018-08-29
    • 1970-01-01
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 2011-08-03
    相关资源
    最近更新 更多