How do you merge two Git repositories?

后端 未结 23 3295
耶瑟儿~
耶瑟儿~ 2020-11-21 05:45

Consider the following scenario:

I have developed a small experimental project A in its own Git repo. It has now matured, and I\'d like A to be part of larger projec

23条回答
  •  长发绾君心
    2020-11-21 06:07

    I kept losing history when using merge, so I ended up using rebase since in my case the two repositories are different enough not to end up merging at every commit:

    git clone git@gitorious/projA.git projA
    git clone git@gitorious/projB.git projB
    
    cd projB
    git remote add projA ../projA/
    git fetch projA 
    git rebase projA/master HEAD
    

    => resolve conflicts, then continue, as many times as needed...

    git rebase --continue
    

    Doing this leads to one project having all commits from projA followed by commits from projB

提交回复
热议问题