Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What <code>read-tree</code> is doing in this case is just adding to a directory in your current tree the contents of another tree. This contents are added just like regular file and directories being created and added, there is no history carried over. All these files will be treated as if you created them.</p> <p>When you try to merge the process fails since it sees that sub_branch history created the <code>data</code> file, and the target directory also contain a different <code>data</code> file created by you.</p> <p>The page you are using is missing a very important step to make subtree works properly, so that you can actually be able to pull updates to it.</p> <p>The proper example can be seen in both these pages: <a href="https://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html" rel="noreferrer">https://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html</a> <a href="https://help.github.com/articles/working-with-subtree-merge" rel="noreferrer">https://help.github.com/articles/working-with-subtree-merge</a></p> <p>What it is missing in your case is to properly link the history when you create the subtree:</p> <pre><code># create the merge record but not change anything in your tree yet git merge -s ours --no-commit sub_branch # bring the changes and place them in the proper subdirectory git read-tree --prefix=sub/ -u sub_branch </code></pre> <p>After this your <code>main</code> repository will contain the history of the <code>sub</code> repository. Calls to the merge that was failing should now work properly. Calling <code>git log --graph</code> will let you see how the different commits are being merged.</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