Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git subtree merged on root of repository (w. git-flow)

We have a repository, git-flow based, where we added an external library as a subtree (using Atlassian SourceTree's git subtree) on the development branch.

Project/
  Library/
    X/
    Y/
    Z/

Later we did a git flow release, merging the changes from develop into master (release).

The problem is when checking out master, the contents of Library get placed on the root of the repository instead of inside Library, like it had lost the git subtree prefix during the merge.

Project/
  X/
  Y/
  Z/

Any idea what's gone wrong?

like image 833
Ramon Poca Avatar asked Dec 02 '14 17:12

Ramon Poca


1 Answers

The subtree itself has its own root directory on its own branch. See http://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging, especially:

You want to pull the Rack project into your master project as a subdirectory. You can do that in Git with git read-tree. You’ll learn more about read-tree and its friends in Chapter 9, but for now know that it reads the root tree of one branch into your current staging area and working directory. You just switched back to your master branch, and you pull the rack branch into the rack subdirectory of your master branch of your main project:

$ git read-tree --prefix=rack/ -u rack_branch

like image 74
user2622016 Avatar answered Oct 14 '22 20:10

user2622016