从 SVN 转换为 Git 时,如何将修订号放入提交消息中?
我们将把我们的存储库从 Subversion 转换为 Git,但希望能够保留 SVN 修订号,因为错误跟踪器中的注释会定期引用它。
我们将使用 git svn clone 以及 中描述的过程约翰·阿尔宾的博客。
有没有办法在提交消息中包含修订号?我更愿意在克隆期间执行此操作,但后处理步骤也是可以接受的。
是的,我知道 git svn find-rev,但这需要 SVN 存储库保留并且用户具有对其的网络访问权限。
We will be converting our repository from Subversion to Git, but would like to be able to retain the SVN revision number as comments in the bug tracker regularly reference it.
We will be using git svn clone
and the process described in John Albin's blog.
Is there a way to include the revision number in the commit message? I'd prefer to do it during the clone, but a post-processing step would be acceptable.
Yes, I know about git svn find-rev
, but that requires the SVN repository stick around and the user has network access to it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
git svn 默认情况下会执行此操作:它通常在每个提交消息中包含一行,其中包含该提交的 SVN 修订号(以及一些其他数据)。
但是,您发布的链接让您使用
--no-metadata
进行克隆,它告诉git svn
不要附加git-svn-id
线。git svn
does this by default: it normally includes a line in every commit message that has the SVN revision number (and some other data) for that commit.However, the link you posted has you cloning with
--no-metadata
, which tellsgit svn
not to append thegit-svn-id
line.目前尚不清楚为什么您希望在提交消息中包含 svn 修订号。正如 @John Flatness 所示,git-svn 在提交消息中包含 svn 修订号。
我们发现为每个修订创建标签更有用。这似乎更符合 svn 修订号的用处。使用 git svn find-rev 的脚本快速添加了 10000 个标签。现在我们可以访问任何历史 svn 修订号。
这里的每个请求都是脚本(在此处添加是因为注释似乎不能很好地处理代码)
这仅执行前 100 个修订。我们在前 5000 转时步进了 1000,然后步进了 100。最后 2000 次左右的提交有单独的标签。
It's not clear why you would want the svn revision number in the commit message. As @John Flatness indicates, the git-svn includes the svn revision number in the commit messages.
We found it more useful to create tags for each revision. This seems to better parallel the usefulness of the svn revision numbers. A script that uses git svn find-rev quickly added 10000 tags. Now we can access any historical svn revision number.
Per request here is the script (added here because comments don't seem to handle code well)
This just does the first 100 revisions. We stepped by by a 1000 for the first 5000 revs then by a 100. The last 2000 or so commits have individual tags.
这个脚本对于使用 svn 的部分分支的人来说效果更好。
因为当没有修订返回时,中断就会消失。试试这个。
只需将 50000 设置为每个最大修订版本号即可。
This script works better for people taking partial branches of svn.
Because the break drops out when no revision returned. Try this one.
Just need to make the 50000 what every your max revision number is.