Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

github - Set Git submodule to shallow clone & sparse checkout?

Many vendor Objective-C libraries (e.g., facebook-ios-sdk) instruct you to copy a certain subset of its repo's files/dirs into your Xcode project. One problem with this is then you do not know what revision of the vendor code you have. Another is that if you make changes to the vendor code, it's not easy to contribute your changes via Git.

As a solution, I want to add each vendor library as a Git submodule of my project's repo with some extra settings (say, in the .gitmodules file). This way, if another person clones my project and does git submodule update --init, their repo & submodules will have the same state as mine because they'll be using the same default settings I set:

  1. Sparse checkout: Only check out certain files of the submodule.
  2. Shallow clone: Only clone a certain SHA1 of the submodule.

How do I set the above settings for a Git submodule?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can do sparse checkouts of submodules the same way as normal sparse checkout. Just remember the sparse-checkout file for each module goes in .git/modules/<mymodule>/info/. But, as discussed in git 1.7 sparse checkout feature, sparse checkouts are exactly that: checkouts. You can't move files or share the settings.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...