Can two identically structured git repos be merged when they have never had any common history?

后端 未结 1 1339
轻奢々
轻奢々 2021-01-02 10:25

I have two small git repos. The projects both started from different points but converged to a very similar one (same file names, folder structure, etc). One is not a bran

相关标签:
1条回答
  • You can fetch one into another:

    $ cd project1
    $ git config remote.project2.url /path/to/project2
    $ git config remote.project2.fetch 'refs/heads/*:refs/project2/*'
    $ git fetch project
    

    That will give you two (or more) branches, containing history of the project1 and project2. They are still completely independent, just use the same object store.

    Then (not tested), you could use a graft file (.git/info/grafts) where you could overwrite the parenthood of a commit (like the first of project2 having for parent the latest of project1)

    As Dustin says in the comments, a rebase is in order in order to "make it permanent", by replaying project2 commits onto project1.


    You have another illustration in this "Using Git within a project (forking around)" blog entry, especially the section "How to pull friends and influence people". Again:

    git checkout two_point_ooh
    git remote add strelau git://gitorious.org/ruby-on-rails-tmbundle/mainline.git
    git checkout -b strelau/two_point_ooh
    git pull strelau two_point_ooh
    

    is a similar process, but for repositories which are forked (which is not exactly your case)

    0 讨论(0)
提交回复
热议问题