Resolving Git Subtree Merge - Entry Overlaps Error - Cannot Bind

This blog article provides a solution to working with git subtrees when you encounter a 'cannot bind' error or subtree merges into the wrong folder.

This article doesn't cover setting up subtrees or compare it to submodules. There are a number of good articles available. These are the guides I followed to get setup with subtrees:

They all follow a similar pattern and don't mention any gotcha's when setting up subtrees. According to the guides the commands needed for my repository should be:

git remote add -f mysubreponame C:\repos\shared-project-code
git merge -s ours --no-commit mysubreponame/master
git read-tree --prefix=location/toplace/subtree/mysub/ -u mysubreponame/master
git pull -s subtree mysubreponame master

All of these guides worked the first time through but subsequent attempts to merge from the subtree into my repository resulted in the merge going into the wrong subdirectory. No problem, right? Simply re-issue the command that was responsible for merging my subtree into the correct directory.

c:\repos\mypoject>git read-tree --prefix=location/toplace/subtree/mysub/ -u mysubreponame/master
error: Entry 'location/toplace/subtree/mysub/readme.txt' overlaps with 'location/toplace/subtree/mysub/readme.txt'.  Cannot bind.

Trying to fix the bind error was actually the wrong place to try and fix the merge issue. The solution involved changing the git read-tree step. This stack overflow article revealed an un-documented option for the git pull command. The -Xsubtree parameter specifies which directory the subtree pull should go into instead of relying on git to try and find it. Changing my final pull command to this merged the subtree changes into the correct directory:

git pull -s subtree -Xsubtree=location/toplace/subtree/mysub mysubreponame master

I hope this guide helped you find the correct place to resolve your git read-tree bind errors and get your subtree merges into the correct subdirectory. 



Share this post

Leave a comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

About Us

Congruity Service is a technology solutions company bringing the best technology solutions to OpenInsight projects, Drupal sites, servers, networks, and your technology needs.