将 SVN 存储库作为分支导入到现有的 Git 存储库中

发布于 2024-10-27 20:07:48 字数 932 浏览 3 评论 0原文

我目前在 google code 上有一个项目,我想将其合并到 Github 上的项目中。

问题是 SVN 项目本质上只是 github 上较大项目的一个文件夹,所以我认为我不能只使用 git-svn 来实现这一点。

我假设我可以使用 git svn 来克隆该项目,但是我不确定如何将 svn 项目正确地移植到现有的 git 项目上。

期望的结果是将 SVN 历史记录放入 Git 分支(而不是将其移植到 master 上)。

能够 dcommit 回 svn 并不是真正必要的(如果有帮助的话)。

已解决

我最终使用了 just_doug 的建议,但做了一些小的修改:

1:我使用了 http://ivanz.com/2009/01/15/selective-import-of-svn-branches-into-a-gitgit-svn -repository/ 将 googlecode 添加为远程引用

2:我为我想要的远程分支创建一个新的 master 分支

3:我使用

git merge -s ours --no-commit googlecode-remote

合并两个

4:然后我使用

git read-tree --prefix=folder1/folder2/ -u googlecode-remote

读取合并历史记录并变基到所需的子文件夹,

希望这可以帮助类似的人情况 ;)

I've currently got a project on google code that I'd like to incorporate into a project on Github.

The issue is that the SVN project is essentially just a folder of the larger project on github, so I don't think i can just use git-svn for this.

I'm assuming I can use git svn to clone the project, but then i'm not sure how to graft the svn project onto the existing git project properly.

The desired outcome would be to get the SVN history into a Git branch (not graft it onto master).

Being able to dcommit back to svn isn't really necessary (if that helps).

SOLVED

I ended up using just_doug's suggestion, but with some minor modifications:

1: I used the suggestions from http://ivanz.com/2009/01/15/selective-import-of-svn-branches-into-a-gitgit-svn-repository/ to add googlecode as a remote ref

2: I create a new branch off of master for the remote branch i wanted

3: I used

git merge -s ours --no-commit googlecode-remote

to merge the two

4: I then used

git read-tree --prefix=folder1/folder2/ -u googlecode-remote

to read in the merge history and rebase to the desired subfolder

hopefully this helps someone in a similar situation ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风念你 2024-11-03 20:07:48

我以前没有使用过它,但听起来你想要 子树合并策略本文提供了有关如何使用它的更多详细信息。

基本上,您将 SVN 存储库添加为远程存储库,然后使用 git read-tree 命令将其“移植”为纯 git 存储库的子目录。根据您希望历史记录的显示方式,您可以执行 git merge -s subtree 将其合并到 pure-git 分支(保留 git-svn 提交),也可以按照以下步骤操作第二个链接并添加 --squash--no-commit 标志,并使合并显示为 pure-git 分支中的单个提交。

这些说明假设远程也是一个 git 存储库。如果本地存储库是使用 git 而不是 git-svn 创建的,则不确定效果如何。这是一种拼凑,但是这里有一些脚本用于制作仅镜像的中间存储库git 中的 SVN 存储库。这样,您可以创建 svn 存储库的 git-svn 镜像,并将其添加为远程,上面的说明应该按描述工作。

I haven't used it before, but it sounds like you want the subtree merge strategy. This article has some more detail on how to use it.

Basically, you add the SVN repository as a remote, then use the git read-tree command to "graft" it in as a subdirectory of your pure git repository. Depending on how you want the histories to show up, you can either do git merge -s subtree to merge it into your pure-git branch (git-svn commits preserved) or you can follow the steps in the second link and add the --squash and --no-commit flags and have the merge show up as a single commit in the pure-git branch.

The instructions assume that the remote is also a git repo. If the local repo was created with git instead of git-svn, not sure how well it will play out. It's kind of a kludge, but here are some scripts for making an intermediate repository that just mirrors an SVN repo in git. This way, you could make a git-svn mirror of the svn repo, and add this as a remote and the instructions above should work as described.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文