"Go" git How to check out the specified file or folder

Source: Internet
Author: User

"Go" git How to check out the specified file or folder
Http://www.handaoliang.com/a/20140506/195406.html

When it comes to project development, there are times when the need is that we just want to get the specified files or folders out of the Git repository. In SVN, this is very easy to implement, because SVN is stored in file mode, and Git is a metadata-based distributed store of file information, it will be in every clone of the time to retrieve all the information to the local, that is equivalent to build a clone version of the repository on your machine. This is therefore not possible until Git1.7.0, but fortunately, after Git1.7.0, the sparse checkout mode is added, which makes it possible to specify a file or folder for check out.

The specific implementation is as follows:

$mkdir-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:

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

You can refer to Git's sparse checkout documentation for details: http://schacon.github.io/git/git-read-tree.html#_sparse_checkout

"Go" git How to check out the specified file or folder

Related Article

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.