Note that there are some explanatory texts on larger screens.

plurals
  1. POGit Subtree Merging reports conflict when merging a simple upstream change
    text
    copied!<p>I'm getting started with learning subtree merging in git 1.8.2. I have created a simple example to test a change to a third party repo migrating into a main project.</p> <p>I'm following the <a href="http://git-scm.com/book/en/Git-Tools-Subtree-Merging" rel="nofollow">6.7 Git Tools - Subtree Merging</a> example. </p> <p>The 'sub' project is included as a subdirectory in the 'main' project.</p> <p>After I make a change to the 'sub' project, git reports a conflict when I try to merge the change into the 'main' project.</p> <p><strong>Test Summary</strong></p> <ol> <li>Created repos for projects 'main' and 'sub' (sub instead of rack)</li> <li>Add remote named sub_remote to main that refers to sub</li> <li>Track sub_remote using sub_branch</li> <li>Change and commit one line in a file in the 'sub' project</li> <li>Pull changes from sub over to main/sub_branch</li> <li>Merge main/sub_branch into main/master.</li> </ol> <p>The merge fails with a conflict. Merge is confused about which version of the changed line to keep.</p> <pre><code>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD main ======= main upstream change &gt;&gt;&gt;&gt;&gt;&gt;&gt; sub_branch main.git sub sub.git tm </code></pre> <p><strong>Complete Test Script</strong></p> <pre><code>#!/bin/sh # initialize empty repos for i in main sub do rm -rf $i{,.git} mkdir $i.git cd $i.git; git --bare init; cd ..; git clone $i.git cd $i echo $i &gt; readme.md git add readme.md git commit -a -m "added readme.md" git push origin master cd .. done # add data to sub ls &gt; sub/data cd sub git add data git commit -m "Added data" git push origin master cd .. # add sub as a sub-tree in main cd main git remote add sub_remote ../sub.git git fetch sub_remote git checkout -b sub_branch sub_remote/master git checkout master git read-tree --prefix=sub/ -u sub_branch git commit -m "Added sub" git push origin master cd .. # make change to sub cd sub sed -i -e 's/main$/main upstream change/' data git commit -a -m "upstream change made to data" git push origin master cd .. # merge sub change to main cd main git checkout sub_branch git pull #merge sub_branch changes into master git checkout master git merge -s subtree sub_branch cat sub/data </code></pre>
 

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