How do I join two git repos without a common root, where all modified files are the same?

后端 未结 2 475
予麋鹿
予麋鹿 2020-12-15 00:12

I have a git-cpan-init of a repo which yielded a different root node from another already established git repo I found on github C:A:S:DBI. I\'ve developed quit

相关标签:
2条回答
  • 2020-12-15 00:56

    A Graft Point would help I think.

    0 讨论(0)
  • 2020-12-15 01:03

    You should be able to add a remote to your existing repository (using git remote add) so that you can fetch the contents of the github repository into your existing repository.

    Assuming that you have a commit in your history (call it O) and a commit in the remote branch (call it R) that correspond to the same set of files (e.g. they are both imports of the same release version), then you can just do an 'onto' rebase. Assuming you have the tip of your changes currently checked out:

    git rebase --onto R O             # R and O are sha1 ids (possibly abbreviated)
    

    This replays all of your commits since O onto the new R root commit.

    Once you've done this, if you are not up to date with the latest remote master branch you can use a normal rebase to get there and git's history tracking will take care that your changes are applied in a way that makes sense.

    git rebase <remote_name>/master   # where <remote_name> is whatever
                                      # you called the github remote when
                                      # you used git remote add
    
    0 讨论(0)
提交回复
热议问题