0

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.

1 Answer 1

2

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 
Sign up to request clarification or add additional context in comments.

5 Comments

I have tried to commit in the submodule directory after pulling the latest code (done in the same manner as the original post showed), then tried to commmit in the submodule directory. I still receive the 'nothing to commit' message.
@NeedsHelp Please add exact steps to your original question. Are you sure you pull from within submodule directory?
The best I can do is show that when I run git diff:A $> git diff diff --git a/deploy b/deploy index bfab259..04e69cf 160000 --- a/deploy +++ b/deploy @@ -1 +1 @@ -Subproject commit bfab2595257ea01722566495997376c47794a5ee +Subproject commit 04e69cfde94be1f94a12fd5291c7bb24a155e344 I get that response, and when I try to update the submodule to move it the new commit hash, it returns it the commit hash back to the old commit hash, bfab25.....
git submodule update does not update submodule to the current version of the submodule as a separate project, but rather points to the specific commit in submodule repo. Please precisely try steps in original answer. Thank you.
Ok. I finally figured it out. I did have some miss understanding of how the 'submodule update' command worked. I was failing to commit after running the 'pull' command, and therefore when I ran 'update' it was reverting me back to old hash. Thanks for the help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.