Set Git submodule to shallow clone & sparse checkout?

后端 未结 3 931
迷失自我
迷失自我 2020-11-27 05:31

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

相关标签:
3条回答
  • 2020-11-27 05:52

    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.

    0 讨论(0)
  • 2020-11-27 05:54

    Submodules can't do part of a repo. You should check out subtree merge instead.

    0 讨论(0)
  • 2020-11-27 06:06

    With git1.8.4 (July 2013), in addition git shallow update for submodule (git submodule update --depth 1), you now can have a custom update:

    In addition to the choice from "rebase, merge, or checkout-detach", "submodule update" can allow a custom command to be used in to update the working tree of submodules via the "submodule.*.update" configuration variable.

    See commit 6cb5728c43f34a7348e128b44b80d00b9417cb19:

    Users can set submodule.$name.update to '!command' which will cause 'command' to be run instead of checkout/merge/rebase.
    This allows the user finer-grained control over how the update is done.

    Signed-off-by: Chris Packham <judge.packham@gmail.com>

    That means you can version a 'command' that you can then use for any submodule update (through the submodule.$name.update setting).
    That script can do a sparse checkout if you want.


    Update August 2016 (3 years later)

    With Git 2.10 (Q3 2016), you will be able to do

     git config -f .gitmodules submodule.<name>.shallow bool
    

    See "Git submodule without extra weight" for more.

    0 讨论(0)
提交回复
热议问题