git archive inside subdirectory

后端 未结 1 1754
攒了一身酷
攒了一身酷 2021-01-15 01:35

I am trying to archive my project regardless of my current directory.

Project structure

main_folder/
    sub1/
    sub2/
        sub3/
相关标签:
1条回答
  • 2021-01-15 02:16

    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.

    0 讨论(0)
提交回复
热议问题