【问题标题】:Pipe git diff to git apply管道 git diff 到 git apply
【发布时间】:2016-02-13 17:12:30
【问题描述】:

为什么这个命令不起作用?

git diff | git --git-dir=/other/location/.git --work-tree=/other/location apply

以下工作完美:

git diff > /tmp/my.patch
cd /other/location && git apply /tmp/my.patch

/other/location是当前目录的镜像。

通过管道命令我得到

error: patch failed: myfile.php:1
error: myfile.php: patch does not apply

【问题讨论】:

  • 您是否尝试使用git diff | git .... apply - 告诉git-apply 使用来自标准输入的补丁数据?

标签: git shell zsh patch


【解决方案1】:

这对我有用 (git 2.6.3):

git diff | git -C /other/location apply

来自man git

-C <path>
       Run as if git was started in <path> instead of the current working
       directory. When multiple -C options are given, each subsequent 
       non-absolute -C <path> is interpreted relative to
       the preceding -C <path>.

【讨论】:

  • 不幸的是,这无济于事。它正在尝试应用补丁,所以它不是看到管道上的字符的问题。
  • FWIW,git -C &lt;path&gt; 开关是相当新的,因此它不适用于安装了各种操作系统的旧版本,例如 1.8.3。
猜你喜欢
  • 1970-01-01
  • 2011-01-04
  • 1970-01-01
  • 1970-01-01
  • 2023-01-09
  • 1970-01-01
  • 2011-12-04
  • 1970-01-01
  • 2015-11-28
相关资源
最近更新 更多