Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have added <code>vendor/plugins/open_flash_chart_2</code> as “gitlink” entry, but never defined it as a submodule. Effectively you are using the internal feature that <em>git submodule</em> uses (gitlink entries) but you are not using the submodule feature itself.</p> <p>You probably did something like this:</p> <pre><code>git clone git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2 git add vendor/plugins/open_flash_chart_2 </code></pre> <p>This last command is the problem. The directory <code>vendor/plugins/open_flash_chart_2</code> starts out as an independent Git repository. Usually such sub-repositories are ignored, but if you tell <em>git add</em> to explicitly add it, then it will create an gitlink entry that points to the sub-repository’s HEAD commit instead of adding the contents of the directory. It might be nice if <em>git add</em> would refuse to create such “semi-submodules”.</p> <p>Normal directories are represented as tree objects in Git; tree objects give names, and permissions to the objects they contain (usually other tree and blob objects—directories and files, respectively). Submodules are represented as “gitlink” entries; gitlink entries only contain the object name (hash) of the HEAD commit of the submodule. The “source repository” for a gitlink’s commit is specified in the <code>.gitmodules</code> file (and the <code>.git/config</code> file once the submodule has been initialized).</p> <p>What you have is an entry that points to a particular commit, without recording the source repository for that commit. You can fix this by either making your gitlink into a proper submodule, or by removing the gitlink and replacing it with “normal” content (plain files and directories).</p> <h2>Turn It into a Proper Submodule</h2> <p>The only bit you are missing to properly define <code>vendor/plugins/open_flash_chart_2</code> as a submodule is a <code>.gitmodules</code> file. Normally (if you had not already added it as bare gitlink entry), you would just use <code>git submodule add</code>:</p> <pre><code>git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2 </code></pre> <p>As you found, this will not work if the path already exists in the index. The solution is to temporarily remove the gitlink entry from the index and then add the submodule:</p> <pre><code>git rm --cached vendor/plugins/open_flash_chart_2 git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2 </code></pre> <p>This will use your existing sub-repository (i.e. it will not re-clone the source repository) and stage a <code>.gitmodules</code> file that looks like this:</p> <pre><code>[submodule "vendor/plugins/open_flash_chart_2"] path = vendor/plugins/open_flash_chart_2 url = git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2 </code></pre> <p>It will also make a similar entry in your main repository’s <code>.git/config</code> (without the <code>path</code> setting).</p> <p>Commit that and you will have a proper submodule. When you clone the repository (or push to GitHub and clone from there), you should be able to re-initialize the submodule via <code>git submodule update --init</code>.</p> <h2>Replace It with Plain Content</h2> <p>The next step assumes that your sub-repository in <code>vendor/plugins/open_flash_chart_2</code> does not have any local history that you want to preserve (i.e. all you care about is the current working tree of the sub-repository, not the history).</p> <p><strong>If you have local history in the sub-repository that you care about, then you should backup the sub-repository’s <code>.git</code> directory before deleting it in the second command below.</strong> (Also consider the <em>git subtree</em> example below that preserves the history of the sub-repository’s HEAD).</p> <pre><code>git rm --cached vendor/plugins/open_flash_chart_2 rm -rf vendor/plugins/open_flash_chart_2/.git # BACK THIS UP FIRST unless you are sure you have no local changes in it git add vendor/plugins/open_flash_chart_2 </code></pre> <p>This time when adding the directory, it is not a sub-repository, so the files will be added normally. Unfortunately, since we deleted the <code>.git</code> directory there is no super-easy way to keep things up-to-date with the source repository.</p> <p>You might consider using a <a href="http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html" rel="noreferrer">subtree merge</a> instead. Doing so will let you easily pull in changes from the source repository while keeping the files “flat” in your repository (no submodules). The third-party <a href="https://github.com/apenwarr/git-subtree" rel="noreferrer"><em>git subtree</em> command</a> is a nice wrapper around the subtree merge functionality.</p> <pre><code>git rm --cached vendor/plugins/open_flash_chart_2 git commit -m'converting to subtree; please stand by' mv vendor/plugins/open_flash_chart_2 ../ofc2.local git subtree add --prefix=vendor/plugins/open_flash_chart_2 ../ofc2.local HEAD #rm -rf ../ofc2.local # if HEAD was the only tip with local history </code></pre> <p>Later:</p> <pre><code>git remote add ofc2 git://github.com/korin/open_flash_chart_2_plugin.git git subtree pull --prefix=vendor/plugins/open_flash_chart_2 ofc2 master git subtree push --prefix=vendor/plugins/open_flash_chart_2 git@github.com:me/my_ofc2_fork.git changes_for_pull_request </code></pre> <p><em>git subtree</em> also has a <code>--squash</code> option that lets you avoid incorporating the source repository’s history into your history but still lets you pull in upstream changes.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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