Note that there are some explanatory texts on larger screens.

plurals
  1. POgit-subtree is not retaining history so I cannot push subtree changes, how can I fix this/avoid this issue in the future?
    primarykey
    data
    text
    <p>I've been using the git-subtree extension (<a href="https://github.com/apenwarr/git-subtree" rel="noreferrer">https://github.com/apenwarr/git-subtree</a>) to manage sub-projects within our main project. It's doing exactly what I want other than the fact that it fails when I try to split out changes made to a sub-project from our main project.</p> <p>e.g. earlier on I had done</p> <pre><code>git subtree add -P Some/Sub/Dir --squash git@gitserver:lib.git master </code></pre> <p>to bring in the library code to Some/Sub/Dir in our main project. Everything here went great so I then pushed my changes to our central main project bare git repo. I then decide to make a change to my local version of the lib in Some/Sub/Dir, commit it, then split it out to push it back to the lib.git repo</p> <pre><code>git subtree split -P Some/Sub/Dir -b some_branch </code></pre> <p>everything works as expected. No longer needing the local copy of the repo I deleted it.</p> <p>After cloning a new copy of the repo from our central repo I made some changes to the lib in Some/Sub/Dir and decided I wanted to split those changes out and push them back to the lib.git repository. I attempt to use the same subtree split command as before, however this time I end up with the following output:</p> <pre><code>1/ 3 (0) 2/ 3 (1) 3/ 3 (1) fatal: bad object d76a03f0ec7e20724bcfa253e6a03683211a7bb1 </code></pre> <p>d76a03f0ec7e20724bcfa253e6a03683211a7bb1 comes from when I added the subtree:</p> <pre><code>commit 43b3eb7d69d5eb64241eddb12e5bd74fd0215083 Author: Ian Bond &lt;ibond@onezero.com&gt; Date: Fri Apr 22 15:06:50 2011 -0400 Squashed 'Subtree/librepoLib/' content from commit d76a03f git-subtree-dir: Subtree/librepoLib git-subtree-split: d76a03f0ec7e20724bcfa253e6a03683211a7bb1 </code></pre> <p>which actually refers to a commit in the lib.git repo.</p> <hr> <p>What I've been able to piece together (and I'm a git noob so I may be wrong, overlooking something, or using incorrect terminology here), is that 'git subtree add --squash' will bring in the entire history from the remote lib.git repo into the current repo, squash it down into a separate commit, then add that commit into the working branch. The lib.git commit history remains in the current repo, however they're dangling commits since they're not actually referenced other than through the text of the squash commit. As long as those dangling commits remain, git-subtree can use them to perform splits, however since a push or pull doesn't contain dangling objects (or if I run a gc and fully prune dangling objects), those dangling commits are lost and git-subtree no longer has the necessary information to perform the split.</p> <p>I've added <a href="http://pastebin.com/0yV8thAk" rel="noreferrer">a script</a> that will fully reproduce the issues I've been having.</p> <hr> <p>My questions are:</p> <p><strong>1)</strong> What can I do to handle the existing situation where I now have subtrees that I want to merge back to their origin repo, but no longer have any sort of history that links them together. My current thought is to do something like:</p> <pre><code>git subtree split -P Some/Sub/Dir 43b3eb7^.. --ignore-joins -b splitBranch </code></pre> <p>to split out all of the history since the 'git subtree add' and merge it back into the origin repo (which thankfully has not had any changes since the add). Is this the best way to go? Any recommendations for how I should perform the merge?</p> <p><strong>2)</strong> Is there anything I can do to make git-subtree work as expected? I believe if I omit the --squash parameter on 'git subtree add' then everything will work, however that causes a bunch of unrelated history to be injected into my repo. Is there some way to keep the needed commits around (preferably without keeping the entire history of the library around)?</p>
    singulars
    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.
 

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