How do I download a single folder on GitHub?

Source: Internet
Author: User

Ce ge
Links: https://www.zhihu.com/question/25369412/answer/96174755
Source: Know
Copyright belongs to the author, please contact the author for authorization.

Git1.7.0 later added sparse checkout mode, which makes it possible to specify a file or folder for check out.


The specific implementation is as follows:

$mkdir project_folder$cd project_folder$git init$git remote add -f origin <url>

The code above will help you create an empty local repository and add the remote git Server url to the git config file.


Next, we allow the use of the sparse checkout mode in config:

$git config core.sparsecheckout true

Next you need to tell git which files or folders you really want to check out, and you can save them as a list in the. git/info/sparse-checkout file.

For example:

$echo “libs” >> .git/info/sparse-checkout$echo “apps/register.go” >> .git/info/sparse-checkout$echo “resource/css” >> .git/info/sparse-checkout

Finally, you just have to pull your project down in the normal way from the branch you want:
$git pull origin master

How do I download a single folder on GitHub?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.