Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>git submodule</code> is implemented as a shell script, so it's easy to see what it's doing — it might be at <code>/usr/lib/git-core/git-submodule</code> if you're using a packaged version. Essentially it just runs <code>git-fetch</code> in the submodule if it the object name (SHA1sum) stored in the main project's tree doesn't match the version checked out in the submodule, as <a href="https://stackoverflow.com/questions/7500741/can-git-submodule-update-be-made-to-fetch-tags-in-submodules/7504682#7504682">Koraktor points out</a>.</p> <p>The <a href="http://www.kernel.org/pub/software/scm/git/docs/v1.7.4.5/git-fetch.html" rel="nofollow noreferrer">documentation for <code>git fetch</code></a> (or <code>man git-fetch</code> while kernel.org is down) says that it should fetch every tag that points to a downloaded object, and the downloaded objects will include every commit that's an ancestor of every branch that's fetched. That means it's surprising to me that you don't get all the relevant tags on a <code>git submodule update</code>.</p> <p>If it's the case that what you really want is for your script is to try to set a new submodule version and commit that result, I don't think that <code>git submodule update</code> is the tool that you want - that's just for making sure that your submodules are at the right version based on what's currently in the main project's commit. Instead you should just do something like:</p> <pre><code>( cd my-submodule &amp;&amp; \ git fetch &amp;&amp; \ git fetch --tags &amp;&amp; \ git checkout my-tag ) git add my-submodule git commit -m 'Update the submodule to the "my-tag" version' my-submodule </code></pre> <p>(I added an extra <code>git fetch --tags</code> <a href="https://stackoverflow.com/questions/1204190/does-git-fetch-tags-include-git-fetch">just in case</a> your tag isn't one that points to a downloaded commit.)</p> <blockquote> <p>Obviously there is another possibility - to point the submodule at the commit which the tag points to rather than the tag itself, but this doesn't seem as neat.</p> </blockquote> <p>Well, the only thing that's stored in the main project's tree for the submodule is just the hash of the commit object, so even if there were a command that said "set my submodule to the tag <code>my-tag</code> in that submodule", it would end up just storing the hash corresponding to that tag anyway...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload