Reputation: 7505
I have two separate git repositories(in BitBucket), Repo A
and Repo B
. I would like to move Repo B
into a subfolder of Repo A
. I also need ensure that the commit history etc. in Repo B
is preserved and not lost.
How can I achieve this with git?
Upvotes: 28
Views: 13174
Reputation: 2434
To merge a Repo B into Repo A as a subfolder, run this command inside Repo A;
git subtree add -P <prefix> <repo> <rev>
Set <prefix>
to the name of the subdirectory, <repo>
to the clone URL of Repo B, and <rev>
to the revision of Repo B you want (HEAD if latest)
This will take the history of Repo B and merge it with Repo A, along with an additional merge commit.
Upvotes: 55
Reputation: 17848
It isn't done in BitBucket, it's done using git. You need the following steps:
merge
the commit you have just created.Upvotes: 3