管道 git 差异到 git 应用
Pipe git diff to git apply
为什么这个命令不起作用?
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 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>.
为什么这个命令不起作用?
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 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>.