Git: How do I clone a subdirectory only of a Git repository?

前端 未结 18 2961
时光说笑
时光说笑 2020-11-21 04:33

I have my Git repository which, at the root, has two sub directories:

/finisht
/static

When this was in SVN, /finisht was chec

18条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 05:07

    So i tried everything in this tread and nothing worked for me ... Turns out that on version 2.24 of Git (the one that comes with cpanel at the time of this answer), you don't need to do this

    echo "wpm/*" >> .git/info/sparse-checkout
    

    all you need is the folder name

    wpm/*
    

    So in short you do this

    git config core.sparsecheckout true
    

    you then edit the .git/info/sparse-checkout and add the folder names (one per line) with /* at the end to get subfolders and files

    wpm/*
    

    Save and run the checkout command

    git checkout master
    

    The result was the expected folder from my repo and nothing else Upvote if this worked for you

提交回复
热议问题