将现有 git 与现有 SVN 存储库同步
好吧,我搞砸了。我有一个包含我的代码的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
git svn dcommit 会回顾分支的历史记录,直到找到包含 git-svn-id: 行的提交消息,因此它将返回到 <正如您所观察到的,在您的情况下,代码> Z 。我会尝试将您的
master
分支重新设置为remotes/git-svn
。我还没有对此进行测试,但我会尝试以下操作:之后,您的历史记录应该如下所示:
...并且 git svn dcommit 应该按预期工作 - 但是,我会首先尝试使用
--dry-run
来确定。git svn dcommit
looks back in the history of your branch until it finds a commit message that contains agit-svn-id:
line, so it'll go back toZ
in your case, as you observe. I would try to rebase yourmaster
branch ontoremotes/git-svn
. I haven't tested this, but the following would be what I would try:After that, your history should look like:
... and
git svn dcommit
should work as expected - however, I'd try it with--dry-run
first, just to be sure.