The git submodule has "new commits" when the validation wizard

I have a submodule called assistants. When I cloned my main project using --recursive, the Helpers submodule is in a separate head state (as all lessons say). If I now 'git status' in the main directory of the project, everything will be clean. If I advise; git checkout master ', I would not expect that nothing will change, except that I am now on a named branch that I can commit. However, doing nothing else if I'm 'cd ..; git status ", I see

modified: Helpers (new commits) 

Why does he think there are new commits? All the same, the submodule must be at the same point as during the update (in this case, cloned), no?

+5
source share
2 answers

If the HEAD your submodule does not match the commit specified in the parent repository index, then git will give you the message “new commits”. You can check what commit is specified in the index by running git ls-tree :

 $ git ls-tree master:<path_to_folder_containing_my_submodule> 160000 commit ba9d11670daf5109a52e5a2b01bca8a344897338 my_submodule 

When you execute a recursive git -on, git will select the most recent and then the HEAD point for the specified commit. If the specified commit does not match the last commit in the remote master, then master will not be HEAD when cloning.

Another way to check after a recursive clone is to cd into your submodule, and then use git log :

 $ git log --decorate --all commit 6a75034cc78fc637e2437bba9f5834835f56bd8f (origin/master, origin/HEAD, master) ... commit ba9d11670daf5109a52e5a2b01bca8a344897338 (HEAD) 

If HEAD and master point to the same commit, you can check the master and you will not see the “new commits” message in the parent repo.

0
source

What is probably happening is that your master submodule is not the version your repo wants to support.

Install your submodule in the version that the repo wants to hold:

 holding/ $ git submodule update 

Check the desired SHA1 submodule:

 holding/ $ git submodule # (1) <list of all submodules, with the desired SHA1> 

Verify that your submodule is master :

 holding/ $ cd sub holding/sub $ git checkout master holding/sub $ git log -1 # (2) 

Is SHA1 at (2) the same as you (1)? If not, this is your problem. Something happened to the submodule master, but these new changes were not included in the holding repo.

A persistent repo supports SHA1 as a link to the version of the submodule used. If further development takes place in the submodule repository, the repository-repository still saves the same version; it does not automatically update the submodule.

If you order a newer version (for example, master ) of a submodule, and then return to the holding repo, git status will tell you that you checked the new commit in your submodule. This change in the current submodule commit can be committed to your holding repository. This will update the version of the submodule version that will be used with this commit.


If you want to continue working on a submodule, from the version that the repo wants to conduct, you will need to create a new branch. master reflects further development in the submodule repository, so either you work from master (and include both this further development and your new work), or you create a new branch from the detached head that is referenced.

If you forced master to a detached head, which would be desirable while holding, what would happen to the commits (hereinafter dev) that were created between the detached head and master ? They will be lost. And what happens the next time you push the moved master to origin ? There will be a conflict because your local master will deviate from origin .

+3
source

All Articles