I am trying to archive my project regardless of my current directory.
Project structure
main_folder/
sub1/
sub2/
sub3/
Currently, the answer is no. You can use
(cd `git rev-parse --show-toplevel`; git archive -v --format zip HEAD) > file.zip
as a workaround.
git-archive has a second parameter to specify a path. The only reason why it can't be used to achieve what you ask for is that, in contrast to many other places in git, this path is interpreted as a relative path rather than a pathspec, which would recognize /
and :(top)
as a repository's root. Maybe they'll add this to git-archive someday.