How to combine two separate unrelated Git repositories into one with single history timeline

后端 未结 2 627
南方客
南方客 2020-12-09 11:24

I have two unrelated (not sharing any ancestor check in) Git repositories, one is a super repository which consists a number of smaller projects (Lets call it repository A).

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 11:57

    I did something similar (merge history from B into A) like this:

    1. go to your repo A
    2. git fetch master:new-branch-on-A (so, you have copied master branch of B into a new branch 'new-branch-on-A' into your repo A.
    3. git checkout new-branch-on-A
    4. git rebase master (you rebase the new-branch-on-A with the master branch)
    5. resolve conflicts if there are any
    6. git checkout master
    7. git merge new-branch-on-A
    8. git branch -d new-branch-on-A
    9. Done :), your histories are merged. I think all commits from A are before commit from B in the new history (git rebase -i is your friend if needed).

提交回复
热议问题