Search code examples
gitgit-submodules

Git: update submodule to the newest version


I have a git project, we will call it 'A', that has a submodule, which we will call 'B'. I have been following the guide from, http://git-scm.com/book/en/Git-Tools-Submodules, and all of the questions here on stackoverflow, but I cannot seem to get project 'A' to change the commit reference for project 'B'. I need help figuring out what I am doing wrong. Here is an example command input/output sequence:

A $> git status
# On branch company
nothing to commit (working directory clean)
A $> cd 'B'
B $> git pull origin master
From https://github.com/company/B
 * branch            master     -> FETCH_HEAD
Updating bfab259..04e69cf
Fast-forward
 Capfile                                            |   45 ++++++++---
 Gemfile                                            |    3 +-
 Rakefile                                           |   86 +++++++++++++------
 config/deploy.rb                                   |   15 +++-
 config/dev.properties                              |    3 -
 config/local.properties                            |   45 ++---------
 config/prod.properties                             |   44 ----------
 config/production.properties                       |   15 ++++
 config/staging.properties                          |   44 ++--------
 config/company.properties                          |   41 ---------
 config/company_test.properties                     |   48 -----------
 .../kafka/producers/Manager.java                   |   33 ++++++--
 .../kafka/producers/http/SysomosClient.java        |    4 +-
 13 files changed, 164 insertions(+), 262 deletions(-)
 delete mode 100644 config/dev.properties
 delete mode 100644 config/prod.properties
 create mode 100644 config/production.properties
 delete mode 100644 config/company.properties
 delete mode 100644 config/company_test.properties
B $> cd ..
A $> git submodule update
Submodule path 'infochimps-deploy': checked out 'bfab2595257ea01722566495997376c47794a5ee'
A $> git commit -a -m "Updated submodule"
# On branch company
nothing to commit (working directory clean)

I am obviously able to pull the new code into the submodule, but when every I update the submodule, it reports the old hash (bfab2595257ea01722566495997376c47794a5ee) still, and when I try to commit after the update git tells me there is nothing to commit.

I am not very experienced with git and could use some help figuring out what I have done wrong. Thanks for the help.


Solution

  • git submodule update is used to keep module up to date with version in your repository.

    In order to update to a newest version from native submodule repo, cd to submodule directory, pull and commit.

    To bring all submodules up to date, you can do:

    git submodule foreach git pull