search

Home  >  Q&A  >  body text

github - How does git synchronize the specified directory under the branch

On Linux, how to clone a directory under a specified branch through the git command.

For example, the branch name is master, and there are three directories aa, bb, and cc below. I only need to clone the directory aa. Other directories do not need to be cloned locally.

Thank you so much.

过去多啦不再A梦过去多啦不再A梦2791 days ago673

reply all(3)I'll reply

  • 滿天的星座

    滿天的星座2017-05-02 09:49:50

    Try git subtree http://aoxuis.me/post/2013-08...

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-02 09:49:50

    sparse checkout

    mkdir myrepo
    cd myrepo
    git init
    git config core.sparseCheckout true
    git remote add -f origin git://...
    echo "path/within_repo/to/desired_subdir/*" > .git/info/sparse-checkout
    git checkout [branchname] # ex: master

    see http://stackoverflow.com/ques...

    reply
    0
  • PHP中文网

    PHP中文网2017-05-02 09:49:50

    Versions before 1.7 are not supported. . There is a sparsecheckout configuration item later, which allows you to clone only some files/directories. In fact, all data is still obtained when pulling, but it is filtered when the local warehouse is updated, so the operation is relatively troublesome.
    Search sparse-checkout online for specific operations

    reply
    0
  • Cancelreply