Tuesday, 5 May 2015

Git - update submodule

Update and merge/rebase local submodule with upstream:

git submodule update --remote --merge
git submodule update --remote --rebase

Under main project directory, see difference of submodule:
git diff --submodule


3 cases:
  • Same commit but submodule has dirty suffix
-Subproject commit c5c6bbaf616d64fbd873df7b7feecebb81b5aee7
+Subproject commit c5c6bbaf616d64fbd873df7b7feecebb81b5aee7-dirty

It means that git status in the submodule isn't clean. cd into the submodule and see what's going on.

  • Different commit, former one is correct (the one in main project)
-Subproject commit c4478af032e604bed605e82d04a248d75fa513f7
+Subproject commit c79d9c83c2864665ca3fd0b11e20a53716d0cbb0
If the former is right, add and commit the new version of the submodule in main project
  • Different commit, latter one is correct (the one in submodule)
If the latter is right, change the version that the submodule is at with:
git submodule update $submodule_name$






Reference:
[1] http://git-scm.com/book/en/v2/Git-Tools-Submodules
[2] http://stackoverflow.com/questions/6006494/git-submodule-modified-files-status

No comments:

Post a Comment