4

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?

1 Answer 1

-3

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.

Sign up to request clarification or add additional context in comments.

5 Comments

no, submodule is the same, but different commits it has in different branches
@logcat try git commit --amend after you have checked out a different commit in the submodule.
Then my last commit from feature going to have submodule hash. It's not what I want. I want to apply submodule hash from master branch to feature.
@logcat this sequence might be helpful: git checkout master git submodule update --init --recursive git checkout feature git commit --amend. Doesn't get easier then this, I suppose.
Please update your answer so that it is useful for people who are coming into a project that already has submodule "weaved" into the workflow, and who need to make useful changes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.