How to sparsely checkout only one single file from a git repository?

前端 未结 21 2113
Happy的楠姐
Happy的楠姐 2020-11-22 08:14

How do I checkout just one file from a git repo?

21条回答
  •  鱼传尺愫
    2020-11-22 09:07

    Two variants on what's already been given:

    git archive --format=tar --remote=git://git.foo.com/project.git HEAD:path/to/directory filename | tar -O -xf -
    

    and:

    git archive --format=zip --remote=git://git.foo.com/project.git HEAD:path/to/directory filename | funzip
    

    These write the file to standard output.

提交回复
热议问题