[英]Apply all commits from one repo to another
Context: My job decided to switch from subversion to git. 上下文:我的工作决定从Subversion切换到git。 They have 5 svn repos that need to be converted, 4 of which are small and can be migrated with git-svn in under an hour.
他们有5个需要转换的svn仓库,其中4个很小,可以在一个小时内用git-svn迁移。 The last is much bigger and git-svn runs for days and eventually crashes, so i've been experimenting with other tools like subgit, svn2git, KDE's svn2git, etc. All of them fail at the same point, a revision over a year ago, and crash.
最后一个更大,并且git-svn运行了好几天,最终崩溃了,所以我一直在尝试其他工具,例如subgit,svn2git,KDE的svn2git等。它们都在同一时间失效,是一年多以前的修订,然后崩溃。
KDE's svn2git has been the fastest and most effective so far, and its rules have allowed me to create two git repos: one with all the commits before the problem, and one with all the commits after. 到目前为止,KDE的svn2git是最快,最有效的,它的规则允许我创建两个git repos:一个包含问题之前的所有提交,一个包含问题之后的所有提交。 Now i need to correctly merge them into one git repo.
现在我需要正确地将它们合并到一个git repo中。
I know how to add one repo as a remote of another and cherry pick the commits over ( git: Apply changes introduced by commit in one repo to another repo ), but I need a way to do it over the entire repo and all its branches. 我知道如何将一个存储库添加为另一个存储库的远程对象,并从中挑选提交内容( git:将由一个存储库中的提交所引入的更改应用于另一个存储库 ),但是我需要一种方法来对整个存储库及其所有分支执行此操作。
How can i apply all of the commits of one repo on top of another? 我如何将一个回购的所有提交应用于另一个?
Edit: I'm looking to do something similar to what git rebase does so that the history is complete and accurate across the entire repository 编辑:我正在寻找与git rebase相似的方法,以便整个存储库中的历史记录完整且准确
You should be able to do it following instructions in this link: http://blog.dynamic50.com/2009/11/26/moving-your-git-repos-and-all-branches-to-a-new-remote-repository/ 您应该能够按照此链接中的说明进行操作: http : //blog.dynamic50.com/2009/11/26/moving-your-git-repos-and-all-branches-to-a-new-remote -存储库/
To sum up, track locally the old branches, add the new remote and then push everything to it. 总结一下,在本地跟踪旧的分支,添加新的遥控器,然后将所有内容推送到其中。
How about this: (Pardon me if it sounds dumb) 怎么样:(如果听起来很蠢,请原谅我)
Assumption: You have two repositories with all commits on one branch. 假设:您有两个存储库,所有提交都在一个分支上。
The awesome guys at Github gave me an answer over email. Github上很棒的家伙通过电子邮件给了我一个答案。
$ cd recenthistory $ git fetch ../oldhistory 'refs/*:refs/remotes/oldhistory/*'
For each branch that appears both in the earlier and the later part of the history: 对于同时出现在历史记录的前半部分和后半部分的每个分支:
$ git rev-list --topo-order --parents refs/heads/$BRANCH | tail [...] bf0c6e839c692142784caf07b523cd69442e57a5 e497ea2a9b6c378f01d092c210af20cbee762475 e497ea2a9b6c378f01d092c210af20cbee762475 8bc9a0c769ac1df7820f2dbf8f7b7d64835e3c68 8bc9a0c769ac1df7820f2dbf8f7b7d64835e3c68 e83c5163316f89bfbde7d9ab23ca2e25604af290 e83c5163316f89bfbde7d9ab23ca2e25604af290
$ echo "e83c5163316f89bfbde7d9ab23ca2e25604af290 $(git rev-parse "refs/remotes/oldhistory/$BRANCH")" >>.git/info/grafts
$ git filter-branch --tag-name-filter cat -- --branches --tags Verify that the history is correct.
$ git push origin --force --all $ git push origin --force --tags
Clone a fresh copy from GitHub and double-check that everything is OK. 从GitHub克隆一个新副本,然后仔细检查一切正常。
Delete the recenthistory and oldhistory repositories (perhaps making backups first). 删除最新历史记录和旧历史记录存储库(也许首先进行备份)。 The histories in these repositories is not compatible with the history in GitHub, so you want to be sure not to do any further work in them.
这些存储库中的历史记录与GitHub中的历史记录不兼容,因此您要确保不要在其中进行任何进一步的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.