git clone part of the code repository

For large code repository, if just want to see and learn some of the source code, selectively download code section path becomes very practical, so you can save a lot of waiting time.

Such as Chromium this, the size of several G is warehouse.

clone warehouse under the code portion of the path in three stages,

  1. Local initialize an empty warehouse, the warehouse target address is set to git distal origin.
  2. Configuration requires the code download path to .git/info/sparse-checkouta file, each line of the plurality of paths can be written.
  3. Finally, execution git pullpull execution code taken.
$ git init <repo>
$ cd <repo>
$ git remote add -f origin <url>

$ git config core.sparseCheckout true

$ echo "some/dir/" >> .git/info/sparse-checkout
$ echo "another/sub/tree" >> .git/info/sparse-checkout

$ git pull origin master

Directory deletions

If you want to follow the path additions and deletions, directly edit the .git/info/sparse-checkoutfile, and then execute git read-tree.

$ vi .git/info/sparse-checkout
$ git read-tree -mu HEAD
#
$ git read-tree --dry-run HEAD

Switch to full mode

If the day did not want to get part of the code, and want to pull the complete code for the entire warehouse, as such, edit .git/info/sparse-checkoutthe file to replace the contents of which are as follows:

/*

And then perform git read-treecan be.

related resources

Guess you like

Origin www.cnblogs.com/Wayou/p/git_sparsecheckout.html
Recommended