简体   繁体   中英

git am with multiple patches

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM