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

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

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

21条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 08:59

    Now we can! As this is the first result on google, I thought I'd update this to the latest standing. With the advent of git 1.7.9.5, we have the git archive command which will allow you to retrieve a single file from a remote host.

    git archive --remote=git://git.foo.com/project.git HEAD:path/in/repo filename | tar -x
    

    See answer in full here https://stackoverflow.com/a/5324532/290784

提交回复
热议问题