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

后端 未结 14 1648
醉梦人生
醉梦人生 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:17

    I had a similar use case, except I wanted to checkout only the commit for a tag and prune the directories. Using --depth 1 makes it really sparse and can really speed things up.

    mkdir myrepo
    cd myrepo
    git init
    git config core.sparseCheckout true
    git remote add origin   # Note: no -f option
    echo "path/within_repo/to/subdir/" > .git/info/sparse-checkout
    git fetch --depth 1 origin tag 
    git checkout 
    

提交回复
热议问题