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

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

    In my case, I want to skip the Pods folder when cloning the project. I did step by step like below and it works for me. Hope it helps.

    mkdir my_folder
    cd my_folder
    git init
    git remote add origin -f <URL>
    git config core.sparseCheckout true 
    echo '!Pods/*\n/*' > .git/info/sparse-checkout
    git pull origin master
    

    Memo, If you want to skip more folders, just add more line in sparse-checkout file.

    0 讨论(0)
  • 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.

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