Git单独checkout子目录

http://schacon.github.io/git/git-read-tree.html#_sparse_checkout

Existing Repository

If you already have a repository, simply enable and configure sparse-checkout as above and do git read-tree.

  1. Enable sparse-checkout:

    git config core.sparsecheckout true
  2. Configure sparse-checkout by listing your desired sub-trees in .git/info/sparse-checkout:

    echo some/dir/ >> .git/info/sparse-checkout
    echo another/sub/tree >> .git/info/sparse-checkout
  3. Update your working tree:

    git read-tree -mu HEAD

可以略过第二步

1.   git config core.sparsecheckout true

2   Update your working tree:

git read-tree -mu HEAD

3

git checkout [branch] -- fileName

原文地址:https://www.cnblogs.com/qq378829867/p/5150935.html