Search code examples
gitgit-submodules

Git submodules and rebase


Using git 1.8.1. I have upstream and local repo for git project.It has one submodule (hash A). Then I branch it out locally to branch "feature" (and have hash A submodule).

  1. Pull some changes and submodule new hash (B) into master branch.
  2. Then I rebase my feature(with submodule hash A) against master branch (with submodule hash B)

When I switch from branch "feature" to branch "master" I see submodule hash is unaffected and still is B for master and A for feature. So I need to update it manually every time.

How can I update "feature" branch to new submodule hash (B) without creating new commit there?


Solution

  • So you want to change the entire submodule from say the linux-kernel to emacs and have git not notice it and act as if nothing was changed?

    Thats not possible because every commit registers with itself the commit(hash) at which all the submodule were when the commit was made and you can safely assume every commit in every git repository to-date has a unique hash. So git will complain if it doesn't find the commit it is looking for in any of its submodule(say in hash B at the HEAD of the feature branch), in case the submodule was changed and you run git submodule update --init --recursive.