git am有多个补丁 [英] git am with multiple patches

查看:114
本文介绍了git am有多个补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将多个补丁从一个git存储库应用于另一个.我使用以下命令创建了补丁:(我想要进行13个最新更改):

  cd repoAgit format-patch -13 -o .. \ patch-directory光盘.. \ repoBgit am .. \ patch-directory \ *.patch 

这给出了:

 致命的:无法打开".. \ patch-directory \ *.patch"以供读取:无效的参数 

一个非常类似的问题,似乎表明这是正确的方法(解决方案

如果您使用的shell不进行whildcard扩展,则您需要自己执行此操作或使用具有该功能的shell.Windows外壳程序不支持,因此您可以使用Git Bash或使用Powershell

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

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

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

I am trying to apply multiple patches from one git repository to another. I've created the patches with (I want the 13 latest changes):

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

This gives:

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

A very similar question, seem to indicate this is the correct method (how to apply multiple git patches in one shot), yet it doesn't work. I can apply the patches individually, by passing the full filenames in multiple commands (and, I could easily create a script to apply them one-by-one), but, I'd like to know why this isn't working.

I am using git version 2.9.2.windows.1.

解决方案

If the shell you are using does not do whildcard expansion then you need to do this yourself or use a shell that does. The Windows shells do not so you can either use Git Bash or if you use Powershell then

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

will do the expansion of the names and then pass all the expanded names as arguments to git am.

An alternative might be the foreach-object call (dir ..\patches\*.patch | ForEach-Object { git am $_}) but I would worry about this handling failed patches correctly.

这篇关于git am有多个补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆