如何在没有公共根的情况下加入两个git仓库,其中所有修改后的文件都是相同的? [英] How do I join two git repos without a common root, where all modified files are the same?

查看:64
本文介绍了如何在没有公共根的情况下加入两个git仓库,其中所有修改后的文件都是相同的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个回购的 git-cpan-init ,它从另一个已经建立的git repo产生了一个不同的根节点,我在github上找到 C:A:S:DBI 。我已经在我的回购中发展了很多,并且我想在更权威的存储库的分支上合并或重放我的编辑。有谁知道如何做到这一点?我认为可以肯定的是,假设修改后的文件的文件内容都不一样 - 代码库自11月8日以来一直没有。

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 quite a bit on my repo, and I'd like to merge or replay my edits on a fork of the more authoritative repository. Does anyone know how to do this? I think it is safe to assume none of the file-contents of the modified files are different -- the code base hasn't been since Nov 08'.

为了清晰起见git hub repo是权威性的。我的本地回购是我想要去git中心显示为一个真正的git分叉。

For clarity the git hub repo is the authoritative one. My local repo is the one I want to go up to git hub shown as a real git fork.

推荐答案

您应该能够在你现有的版本库中添加一个远程文件(使用 git remote add ),这样你就可以将github版本库的内容读取到你现有的版本库中。

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.

假设您在历史记录中提交了一个提交(称为O)并在远程分支中提交了一个提交(称为R),这些提交对应于同一组文件(例如,它们都是导入相同的发布版本),那么你可以做一个'上'重组。假设您已经将您的更改提示当前检出:

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)

这将重放所有提交,因为O会进入新的R根提交。

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

完成此操作后,如果您没有及时了解最新的远程主分支,那么您可以使用正常的重新分配来实现此目的,并且git的历史记录会照顾到您的

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

这篇关于如何在没有公共根的情况下加入两个git仓库,其中所有修改后的文件都是相同的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆