Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git submodule new version update

I had forked a MapBox-ios-sdk and make some changes to it. A newer release of the sdk is here and I merged my the changes into my fork. MapBox-ios-sdk also incorporate SMCalloutView which is a submodule within MapBox-ios-sdk. However the version of the official sdk uses a newer, updated SMCalloutView that's not in my fork.

How do I get it to update

I update my sdk with instructions from here. However this does not update SMCalloutView. I also tried git submodule update --recursive at the level of the MapBox-ios-sdk and nothing happens. As it turns out it's because SMCallOutView is in "no branch". Why is it at "no branch"? How do I bring all the submodule out of the state of "no branch"? If it's at "no branch" then I'd never know which submodule or submodule of the submodule (or even more nested) that needs update.

like image 671
huggie Avatar asked Jun 19 '13 14:06

huggie


1 Answers

With git 1.8.2+ (March 2013), you can define a submodule which will reflect the latest commit of a given branch.
See "git submodule tracking latest".

It means this would be enough to update a submodule to the latest of a branch:

# --remote will also fetch and ensure that
# the latest commit from the branch is used
git submodule update --remote

See git repo commit 06b1ab for more on the --remote option.


To recap:

  • For a new submodule (which must follow a branch):

    git submodule add -b [branch] [URL] [DirectoryName]
    
  • For an existing submodule that you now want it to follow a branch:
    See also git repo commit b92892, for transforming a git submodule into one which follows a branch.
    All you need to do is:

    git config -f .gitmodules submodule.<path>.branch <branch>
    

    See more at "Git submodules: Specify a branch/tag"

like image 184
VonC Avatar answered Oct 08 '22 10:10

VonC