I need to create an archive of changed files only between two commits. I use this command:
git archive -o changes.zip HEAD $(git diff --name-only --diff-filter=d a1be79f0 HEAD)
. It works fine for small amount of changes. But now I have added a new module in the repository which includes a large number of new files. In windows, the command $(git diff --name-only --diff-filter=d a1be79f0 HEAD)
results in a large number of file paths and hence exceeds single command length. I think it would be fine if I write the output of the git diff
command in a file and pass that file to git archive
. But I cannot find a way to feed a large number of file paths to git archive
.
Asked
Active
Viewed 46 times
2

Chitholian
- 432
- 1
- 10
- 19
-
Why do you think it exceeds the command length? This may be an issues with zip tool. There are a number of different versions of zip specification with optional sections. Zip tools work well when you do not add additional files to an existing archive. Problems seem to occur after adding additional files to an existing zip. Not all tools add the additional files the same way and then there are issues with reading the zip. This sounds like you cannot read all the files, and not a length issue. – jdweng Mar 21 '23 at 04:57
-
@jdweng, I think so because of the error message: ResourceUnavailable: Program 'git.exe' failed to run: An error occurred trying to start process 'C:\Program Files\Git\cmd\git.exe' with working directory 'D:\PATH-TO-REPO'. The filename or extension is too long.At line:1 char:1 + git archive -o changes.zip HEAD $(git diff --name-only a1be79f08 HEAD … – Chitholian Mar 21 '23 at 05:08
-
Is the d:\drive a mapped drive to a network location? The error is due to the network pathname being too long, not the files inside the zip archive. Move the zip to your c:\ drive and try again. – jdweng Mar 21 '23 at 08:54
-
@jdweng, D:\ is a local drive, nothing is network-shared. The error message does not appear if I run `git archive -o changes.zip HEAD`. – Chitholian Mar 21 '23 at 09:48
-
A zip file is an archive that is structure the same as a file system with cylinders and sectors, directories, and subdirectories. There is a ZIP specification with different versions and optional features. I've seen lots of issues over the years when ZIP are created by one utility and then unzip with different utility. Especially when new files are added to and existing archive and archives are created over the network. Windows have folder-filename max lengths like 128 or 256 characters which seems to be your error. I would try to unzip your file with same tool that created the zip. – jdweng Mar 21 '23 at 10:56