Trying to make zip archive with such command
git archive -v -o app.zip --add-file=.env --add-file=.ebextensions/my-scripts.config HEAD
2 not versioned files are added via --add-file option.
Problem is that my-script.config added to the root of archive, but I need it inside .ebextensions folder as it was initially.
Is there any way to achieve it with git archive command?
CodePudding user response:
This isn't documented anywhere, so I'm not sure how much you should count on it, but testing shows that it works:
git archive -v -o app.zip \
--add-file=.env \
--prefix=.ebextensions/ --add-file=.ebextensions/my-scripts.config \
--prefix= HEAD
(all as one line without the backslash-newline, or leave in the backslashes in sh / bash) does the trick with Git version 2.34. Based on the code, it should work in all the versions of Git that have --add-file
(2.29 and later). Essentially, --prefix
sets the current prefix; --add-file
adds a file whose pathname consists of the prefix plus the tail part of the path, and --prefix
then replaces the prefix, so that you don't have to affect the rest of the action.