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

I think you do it like this:

  1. git remote add [repo b]
  2. git fetch//get the repo b into repo a
  3. due to you want to keep the history like this: A0-A1-B1-B0-D1-C0-D0-E0-F0-G0-E1-H(from repo B)-HEAD (new repo A) you can first select the A0 as a start point, after that, use git cherry-pick one by one.

Hope this is useful for you.

Br, Tim


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

  1. go to your repo A
  2. git fetch <ref to your repo B> 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).

Tags:

Git

Git Merge