【问题标题】:git am with multiple patches带有多个补丁的 git am
【发布时间】:2016-12-21 17:28:49
【问题描述】:

我正在尝试将多个补丁从一个 git 存储库应用到另一个。我已经创建了补丁(我想要 13 个最新更改):

cd repoA
git format-patch -13 -o ..\patch-directory
cd ..\repoB
git am ..\patch-directory\*.patch

这给出了:

fatal: could not open '..\patch-directory\*.patch' for reading: Invalid argument

一个非常相似的问题,似乎表明这是正确的方法(how to apply multiple git patches in one shot),但它不起作用。我可以通过在多个命令中传递完整的文件名来单独应用补丁(并且,我可以轻松地创建一个脚本来逐个应用它们),但是,我想知道为什么这不起作用。

我正在使用git version 2.9.2.windows.1

【问题讨论】:

  • 您是否尝试过使用绝对路径?看看这个答案:stackoverflow.com/a/29888775/2531279
  • 提供绝对路径也不起作用,同样的错误。
  • 你试过format-patch--relative 参数吗?
  • --relative 传递给format-patch 会创建与没有传递完全相同的补丁,因此仍然不起作用。
  • 我遇到了同样的错误,并且能够使用随 git (https://git-scm.com/downloads) 一起安装的 Git bash 使其工作。

标签: git patch


【解决方案1】:

如果您使用的 shell 不进行通配符扩展,那么您需要自己执行此操作或使用可以执行此操作的 shell。 Windows shell 没有,所以你可以使用 Git Bash 或者如果你使用 Powershell,那么

git am (dir ..\patches\*.patch)

将对名称进行扩展,然后将所有扩展的名称作为参数传递给git am

替代方法可能是 foreach-object 调用 (dir ..\patches\*.patch | ForEach-Object { git am $_}),但我会担心这种处理失败的补丁是否正确。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-08
    • 2018-08-25
    • 2016-07-11
    • 1970-01-01
    • 2015-07-07
    • 2015-04-29
    • 2019-09-23
    • 2015-05-21
    相关资源
    最近更新 更多