管道git差异到git应用

管道git差异到git应用,git,shell,zsh,patch,Git,Shell,Zsh,Patch,为什么这个命令不起作用 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.p

为什么这个命令不起作用

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
这对我很有用(
git2.6.3
):

mangit

-C
就像git是在中启动的一样运行,而不是当前工作
目录当给出多个-C选项时,每个后续选项
非绝对-C是相对于
前面的-C。

不幸的是,这没有帮助。它正在尝试应用补丁,这样就不会出现在管道上看到字符的问题。FWIW,
git-C
开关是相当新的,因此这在安装了各种操作系统的1.8.3等旧版本中不起作用。您是否尝试过使用
git diff | git。。。。apply-
告诉git apply使用标准输入的补丁数据?
git diff | git -C /other/location apply