Is it possible to do a sparse checkout without checking out the whole repository first?

后端 未结 14 1835
醉梦人生
醉梦人生 2020-11-22 09:32

I\'m working with a repository with a very large number of files that takes hours to checkout. I\'m looking into the possibility of whether Git would work well with this kin

14条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 10:30

    I found the answer I was looking for from the one-liner posted earlier by pavek (thanks!) so I wanted to provide a complete answer in a single reply that works on Linux (GIT 1.7.1):

    1--> mkdir myrepo
    2--> cd myrepo
    3--> git init
    4--> git config core.sparseCheckout true
    5--> echo 'path/to/subdir/' > .git/info/sparse-checkout
    6--> git remote add -f origin ssh://...
    7--> git pull origin master
    

    I changed the order of the commands a bit but that does not seem to have any impact. The key is the presence of the trailing slash "/" at the end of the path in step 5.

提交回复
热议问题