Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Subtree prefix path

I have a problem with GIT subtrees.

Let's see, I have a project A which consists of:

Project A
|_CodeFolder1
|_CodeFolder2
|_SharedFolder1
|_SharedFolder2

Let's say I make a new repo that just has SharedFolder1 and SharedFolder2.So I remove those two folders from the main repo, and add them to the new shared repo, which would look like this:

SharedProject
|_SharedFolder1
|_SharedFolder2

I'm newbie to subtrees, but till now I achieved to pull/push from remote subtrees. But I'm having a problem. When I add the subtree, I must add a prefix, but I don't want to save the shared code in a different folder, like:

Project A
    |_CodeFolder1
    |_CodeFolder2
    |_SharedFolders
             |_SharedFolder1
             |_SharedFolder2

Which is what the --prefix makes whenever I try to add the subtree:

git subtree add --prefix=SharedFolders --squash shared master

Is there any way I can tell git that there's no prefix, or that the subtree must be saved in ProjectA directly, like in the first schema, without creating a new folder for the subtree?

I tried this command

git subtree add --prefix=/ --squash shared master

But there's always an error. Seems that subtree won't let me take the folders from the tree directly to my working path without creating a new folder for the shared files.

Any help would be much appreciated.

like image 745
aran Avatar asked May 21 '14 09:05

aran


1 Answers

Ok, I got the answer. The correct syntax is:

git subtree add --prefix= --squash shared <branch>

And for pulling:

git subtree pull --prefix=/ --squash shared <branch>
like image 176
aran Avatar answered Sep 25 '22 12:09

aran