将现有 git 与现有 SVN 存储库同步

发布于 2024-11-03 21:12:24 字数 759 浏览 3 评论 0原文

好吧,我搞砸了。我有一个包含我的代码的 SVN 存储库,还有一个本地 git 存储库,我通常在其中工作、分支等。我曾经使用 git-svn 时不时地将内容从 git 提交到 SVN。现在我有了一台新电脑,并将我的 git 存储库从一台克隆到另一台。后来我尝试使用 git-svn ,但由于新版本和我不够小心,配置不知何故丢失了。所以我使用 git svn init 和 clone 来取回我在 SVN 中的历史记录,但现在情况如下:

o--Z--o--....--X--o--o....--o  (master)
   |
   o--o--o--....--X (remotes/git-svn)

X 正在标记一个状态其中两个存储库处于相同的状态(因为 master 和 git-svn 在我的旧机器上同步)。现在,我想将 master 从 X 到 HEAD 的所有内容提交到我的 SVN 存储库中,但是当我使用 git svn dcommit -n 时,它会显示回到 Z 的差异. 如何再次同步 git-svn 和 git 和 svn (以便我可以简单地使用 dcommit 再次提交内容)?

是否可以返回 X 并使用 git svn set-tree X (因为当前 SVN 完全保留该版本),然后返回 HEAD 执行 <代码>git svn dcommit?我不想(盲目地)尝试 SVN 上的东西,因为里面有很多东西(由许多其他人提供),我不想搞砸。

Okay, I made a mess. I have a SVN repository with my code and I have a local git repository in which I usually work, branch, etc.. I used to commit things from time to time from git into SVN using git-svn. Now I got a new computer and cloned my git repository from one to the other. I tried to use git-svn afterwards, but due to a new version and me being not careful enough the configuration was somehow lost. So I used git svn init and clone to get back my history in SVN, but now the situation looks like this:

o--Z--o--....--X--o--o....--o  (master)
   |
   o--o--o--....--X (remotes/git-svn)

X is marking a state in which both repositories are in the same state (as master and git-svn where in sync on my old machine). Now, I'd like to commit everything from X to HEAD from master into my SVN repository, but when I use git svn dcommit -n it shows diffs way back to Z. How can I sync git-svn and git and svn again (so that I can use simply dcommit to commit stuff again)?

Is it possible to go back to X and use git svn set-tree X (because the current SVN holds exactly that version) and than go back to HEAD to do the git svn dcommit? I don't want to (blindly) try stuff on the SVN, as there is a lot of more stuff in it (by many other people) which I don't want to screw up.

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

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

发布评论

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

评论(1

脸赞 2024-11-10 21:12:24

git svn dcommit 会回顾分支的历史记录,直到找到包含 git-svn-id: 行的提交消息,因此它将返回到 <正如您所观察到的,在您的情况下,代码> Z 。我会尝试将您的 master 分支重新设置为 remotes/git-svn。我还没有对此进行测试,但我会尝试以下操作:

 # Make sure that you're on master
 git checkout master

 # Create a new branch here to save the old branch
 git branch old-master

 # Rebase everything after the X on master up to the tip of master
 # onto remotes/git-svn
 git rebase --onto remotes/git-svn <commit-ID-of-X-in-master> master

之后,您的历史记录应该如下所示:

o--Z--o--....--X--o--o....--o  (old-master)
   |
   o--o--o--....--X (remotes/git-svn) --o--o....-o (master)

...并且 git svn dcommit 应该按预期工作 - 但是,我会首先尝试使用 --dry-run 来确定。

git svn dcommit looks back in the history of your branch until it finds a commit message that contains a git-svn-id: line, so it'll go back to Z in your case, as you observe. I would try to rebase your master branch onto remotes/git-svn. I haven't tested this, but the following would be what I would try:

 # Make sure that you're on master
 git checkout master

 # Create a new branch here to save the old branch
 git branch old-master

 # Rebase everything after the X on master up to the tip of master
 # onto remotes/git-svn
 git rebase --onto remotes/git-svn <commit-ID-of-X-in-master> master

After that, your history should look like:

o--Z--o--....--X--o--o....--o  (old-master)
   |
   o--o--o--....--X (remotes/git-svn) --o--o....-o (master)

... and git svn dcommit should work as expected - however, I'd try it with --dry-run first, just to be sure.

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