Reputation: 1985
I have two repositories, let's say Repo A and Repo B with the structures as shown below:
Repo A (there are many files in each repo. I am just showing 2 files for example):
|
|
|---Test1.cs (It has some changes made by X Developer)
|---Test2.cs (It has some changes made by X Developer)
Repo B:
|
|
|---src
|
|
|---Test1.cs (It has some changes made by Y Developer)
|---Test2.cs (It has some changes made by Y Developer)
I want to merge (or rebase) of files from Repo A to Repo B/src, without losing history. After the merge, when I view history, I want to see both Developer X and Y changes. Is this possible? If yes, please guide me how to do this.
I have looked other SO posts and tried adding remote repo, etc. But those are not covering this type of scenario. My GIT version is 2.21.0.
Upvotes: 2
Views: 623
Reputation: 1547
You can use a normal merge for this, but you will have to use merge --allow-unrelated-histories
to allow unrelated histories to merge.
For example:
cd target-repository
# we work on master
git checkout master
# add the repository as a remote
git remote add other /path/to/source-repo
# fetch the remote repository, which will create other/master
git fetch other
# merge the histories, specifiy --allow-unrelated-histories to avoid the related history check
git merge --allow-unrelated-histories other/master
This assumes that files do not overlap.
Upvotes: 1