Note that there are some explanatory texts on larger screens.

plurals
  1. POGit commit to common submodule (master branch)
    primarykey
    data
    text
    <p>I've two or more projects (let's call them <em>ProjectFoo</em> and <em>ProjectBar</em>) having some <strong>common code</strong> that I put in a <strong>submodule</strong>.</p> <p>My understanding is that if I commit changes to a submodule from within <em>ProjectFoo</em> it'll be in a detached head that only all <em>ProjectFoo</em> clones can see:</p> <pre><code>(master) $ cd ProjectFooBarCommoneSubmodule/ (master) $ git commit -am "Common code fix." (56f21fb0...) $ git push Everything up-to-date </code></pre> <p>That's probably because the <code>master</code> branch hasn't changed. I could probably do something like <code>git checkout master &amp;&amp; git merge Everything up-to-date</code> but that seem pretty ugly. May be a <code>git reset --hard master</code> would do the same but it seems even uglier.</p> <p>How to have a common code shared by project, updated <strong>from within</strong> those projects using it? In other words, committing to that submodule should update all various repositories (<em>repositories, not just clones</em>) that use this same submodule.</p> <p>---- EDIT ----</p> <p>Visibly my checked-out repository was messed up and broken. It should have worked right from the start like that (on <em>ProjectFoo</em> in this example):</p> <pre><code>(master) $ cd ProjectFooBarCommoneSubmodule/ (master) $ git commit -am "Common code fix." (master) $ git push .... fbfdd71..0acce63 master -&gt; master (master) $ cd .. (master) $ git add ProjectFooBarCommoneSubmodule (master) $ git commit -m "Submodule update." </code></pre> <p>Then to get that change from on other projects, like <em>ProjectBar</em>:</p> <pre><code>(master) $ cd ProjectFooBarCommoneSubmodule/ (master) $ git pull </code></pre> <p>Would update to the latest common code. A <code>git checkout master</code> may be required if it's on a detached head.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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