git的存档"输入线过长。 "错误批处理文件 [英] git archive "The input line is too long. " error in batch file

查看:162
本文介绍了git的存档"输入线过长。 "错误批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我设法修改脚本,我发现创建以来增加或变更2之间更改的文件的归档各种来源。批处理脚本如下:

From various sources I managed to modify a script I found to create an archive of the files that were added or changed between 2 changesets. The batch script is as follows:

setlocal enabledelayedexpansion
set output=
for /f "delims=" %%a in ('git diff --name-only %1 %2') do ( set output=!output! "%%a" )
git archive -o export.zip HEAD %output%
endlocal

本已直到今天伟大的工作,并突然我收到以下错误回:

This has worked great until today and all of a sudden I am getting the following error back:

输入线过长。该命令的语法不正确。

The input line is too long. The syntax of the command is incorrect.

我已经证实了这个原因是产量%的%的结果是太长,但不知道是否或如何可以解决此?

I've confirmed that the cause of this is the that result of %output% is too long but not sure if or how I can work around this?

推荐答案

如果你想改变文件导出两次提交,为什么不(上,而不是依靠DOS变量被设置,并成为潜在的太长)做的:

If you wanted to export changed files between two commits, why not (instead on relying on DOS variable being set, and being potentially too long) do a:

git archive --output=file.zip HEAD $(git diff --name-only SHA1 SHA2)

既然是Unix的语法,你需要调用包含在Git中的sh.exe的Windows(正如我在提什么是的Git的Bash的确切含义是什么?」)

href=\"http://stackoverflow.com/users/194884/pronotion\"> OP ProNotion 建议<一的in该评论

The OP ProNotion proposes in the comments:

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i -c "git archive -o export.zip HEAD $(git diff --name-only %1 %2)" 

这篇关于git的存档&QUOT;输入线过长。 &QUOT;错误批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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