Intro
I faced a situation that I would like to merge two repositories and keep to remain these histories.
I figured out it, so I write the way down on this article so I won't forget.
I will use Fork(Git client) but it is possible command line too.
Step1
First, I created two sample repositories and just kind of some commits.
A repository named "MergeTest1".
A repository named "MergeTest2".
Step2
This time, I will merge "MergeTest2" to "MergeTest1".
On the condition of what you have already had two repositories at local, a next step is add another repository as new remote repository.
And fetch all remote, checkout another repository.
Step3
A final step is merge.
A base is master(MergeTest1), so checkout master(MergeTest1) and try to merge master2(MergeTest2).
This time, I deliberately prepared conflict.
A below GIF is a resolving step.
If you avoid conflict, I recommned to evacuate your file at an other folder in advance.
Other Resources
Gitで2つのリポジトリを履歴を残したままマージする方法
Git MergeでConflictが発生したときの対処 - プログラミング初心者がアーキテクトっぽく語る
Top comments (0)