SVN 到 git ...现在 git 到 SVN。这么多冲突

发布于 2024-08-06 08:10:26 字数 646 浏览 1 评论 0原文

免责声明:如果我一开始就知道 git-svn ,事情会更简单。

我在 SVN 中有一个很大的代码库,并且粗略地把它放在了 git 中。如果没有快速、高效的分支,工作生活会非常痛苦,所以这一切都是仓促完成的。我的流程是:

svn export
git init .
git add .
git commit -a -m "initial commit"

现在我已经完成了我的小型分支项目。我能够在一个干净的分支中“救火”并在其他分支上进行开发。太棒了。我的分支现在已全部合并回一个分支,我已准备好将此代码返回到 SVN 中。

我现在已经使用 git-svn 进行了一些工作,已经设置并获取了 svn 存储库。但这是我所能得到的。

假设我的 git 分支是“master”,并且我的 git-svn 存储库是“svnrepo”:

git checkout master
git rebase svnrepo

失败并引发大量合并冲突和“索引中已存在”错误。

git checkout svnrepo
git rebase master

以完全相同的方式失败。

如何保留 git 历史记录并将此代码返回到 SVN 中?

Disclaimer: Things would be simpler had I known about git-svn at the start.

I had a large codebase in SVN, and crudely got it situated in git. Work life was very painful without fast, efficient branching, so this was all accomplished in a bit of a rush. My process was:

svn export
git init .
git add .
git commit -a -m "initial commit"

Now I'm done with my small branch projects. I was able to "fight fires" in a clean branch and do development on others. It was great. My branches are all now merged back into one, and I'm ready to get this code back into SVN.

I've worked a bit with git-svn now, having gotten the svn repo setup and fetched. But that's as far as I can get.

Assuming my git branch is "master", and my git-svn repo is "svnrepo":

git checkout master
git rebase svnrepo

fails and throws masses of merge conflicts and "already exists in index" errors.

git checkout svnrepo
git rebase master

fails exactly the same way.

How can I preserve git history and get this code back into SVN?

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

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

发布评论

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

评论(1

小…楫夜泊 2024-08-13 08:10:26

我会执行一系列 git在“svnrepo”分支上进行cherry-pick操作,以移动“master”分支中的每个相关提交(从最旧的开始)。樱桃采摘在很大程度上与每个提交的祖先无关,并且会尝试应用补丁而不关心它来自哪里。一旦您完成了所有提交的挑选,请使用 git svn dcommit 将它们提交到 Subversion。

请注意,如果“master”分支上有任何非线性历史记录,您将需要在将代码推回到 Subversion 之前尝试将其展平。这可能需要一些额外的工作,但由于 Subversion 不支持非线性历史,因此这几乎是必需的步骤。

I would do a sequence of git cherry-pick operations on your "svnrepo" branch to move over each relevant commit from the "master" branch (starting with the oldest). Cherry picking is largely agnostic regarding the ancestry of each commit, and will try to apply the patch without being concerned where it came from. Once you have finished cherry-picking all the commits, use git svn dcommit to commit them to Subversion.

Note that if you have any nonlinear history on the "master" branch, you will want to try to flatten this out before pushing your code back up to Subversion. This may require a bit of extra work but since Subversion doesn't support nonlinear history, it's pretty much a required step.

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