修复缺少分支点的远程 git-svn 分支的历史记录
我使用 git-svn 与远程 svn 存储库进行交互,该存储库遵循主干、标签和分支的传统布局。
svn
中有一个分支,git
错过了它的历史记录。我知道历史是:
r0--r1--r2---r4---r6 remotes/trunk
\
r3---r5-- remotes/BRANCH_NAME
但 git 似乎错过了分支点并认为历史是:
r0---r1---r2-----r4---r6 remotes/trunk
r0'--r1'--r2'--r3--r5--- remotes/BRANCH_NAME
其中 r0'
, r1'
, and r2'< /code> 是出现在 git 中但不出现在 svn 中的
r0
、r1
和 r2
的副本。在 svn 中只有一次 r0
提交。
.git/svn/refs/remotes/BRANCH_NAME/unhandled.log.gz
中的第一个条目可能会为专家提供线索:
r3
+dir_prop: . svn:mergeinfo /product/trunk/src_py:371-436%2C438-532
How do I get git to recognize that r3
是从 r2
分支出来的,并取消了 r2'
、r1'
和 r0'
?
额外加分:是否有一种通用方法可以重写 git 的 svn 历史记录视图,并且不会被 git svn fetch 等人破坏?
I'm using git-svn
to interact with a remote svn
repsitory that follows the traditional layout of trunk, tags, and branches.
There's a branch in svn
that git
has missed the history of. I know the history to be:
r0--r1--r2---r4---r6 remotes/trunk
\
r3---r5-- remotes/BRANCH_NAME
But git seems to have missed the branch point and thinks the history is:
r0---r1---r2-----r4---r6 remotes/trunk
r0'--r1'--r2'--r3--r5--- remotes/BRANCH_NAME
Where r0'
, r1'
, and r2'
are copies of r0
, r1
, and r2
that appear in git, but not in svn. In svn there is exactly one r0
commit.
The first entry in .git/svn/refs/remotes/BRANCH_NAME/unhandled.log.gz
may offer the experts a clue:
r3
+dir_prop: . svn:mergeinfo /product/trunk/src_py:371-436%2C438-532
How do I get git to realise that r3
was branched from r2
and do away with r2'
, r1'
, and r0'
?
For extra credit: Is there a general way to rewrite git's view of svn history, that won't get clobbered by git svn fetch
et al?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
结果是日志消息中的 git-svn-id URL 不同,从而改变了 SHA1。例如
http://hostname/repo
和http://hostname.org.ext/repo
。我使用 gitbranch-filter --msg-filter 来更新每次提交中的 git-svn-id 标记,问题就消失了。 (当然,运行 git gc 来清除我的存储库中的所有冗余提交)
It turned out to be the
git-svn-id
URL in the log messages that was different, thus altering the SHA1. E.g.http://hostname/repo
andhttp://hostname.org.ext/repo
.I used
git branch-filter --msg-filter
to update thegit-svn-id
marker in every commit and the problem went away. (And of course rangit gc
to scrub all the redundant commits from my repo)我建议您使用 SmartGit 而不是 git-svn。它可以正确处理此类 SHA1 更改。
或者,如果您有权访问 SVN serevr,请安装 SubGit 到其中。 SubGit 将创建一个可供您使用的链接 Git 存储库。 SVN 和 Git 存储库将始终保持同步。所以你可以只使用 Git 界面。
I would recommend you to use SmartGit instead of git-svn. It handles such SHA1-changes correctly.
Or alternatively, if you have an access to the SVN serevr, install SubGit into it. SubGit will create a linked Git repository that you can work with. SVN and Git repositories will always be in sync. So you can use just Git interface.