Reputation: 147
I want to merge a repository into a folder of an other repository.
Currently, it looks like this :
I have multiple repositories like A, B, C,..
-> A
.git
-> B
.git
-> C
.git
And then I have only one repository for example called R which contains folder A,B,C (which are not git repositories but only folder which contains almost the same stuff than the previous A,B,C git repositories) :
-> R
.git
A
B
C
I want to merge A repository with the A folder in R repository, B repository with the B folder in R repository, etc.
What would be the best solution ?
Upvotes: 4
Views: 917
Reputation: 1260
The structure of the tree
s in a git repository for a branch determine the resulting merge. I don't believe you can say "merge this branch from this remote, but merge it into this folder", since that would require git to re-interpret all the tree
objects.
I'm not sure what you are allowed to do with your repos A, B and C, but if i restructure repo A to have an "A" folder to mimic "R", i can e.g. git merge repoA/master --merge-unrelated-histories
after adding repoA
as a remote.
zrrbite@ZRRBITE MINGW64 /d/dev/git/repotest (master)
$ git fetch repoA
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From D:/dev/git/repotest_A
b73c55c..0b2748b master -> repoA/master
zrrbite@ZRRBITE MINGW64 /d/dev/git/repotest (master)
$ git merge repoA/master --allow-unrelated-histories
Merge made by the 'recursive' strategy.
A/file_from_A.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 A/file_from_A.txt
zrrbite@ZRRBITE MINGW64 /d/dev/git/repotest/A (master)
$ ls
file_from_folder_A.txt file_from_repo_A.txt
If i had files with identical names e.g. file_from_folder_A.txt
then i would simply get a merge-conflict to solve:
zrrbite@ZRRBITE MINGW64 /d/dev/git/repotest (master)
$ git merge repoA/master --allow-unrelated-histories
CONFLICT (add/add): Merge conflict in A/file_from_folder_A.txt
Auto-merging A/file_from_folder_A.txt
Recorded preimage for 'A/file_from_folder_A.txt'
Automatic merge failed; fix conflicts and then commit the result.
zrrbite@ZRRBITE MINGW64 /d/dev/git/repotest (master|MERGING)
...
Upvotes: 3