简体   繁体   English

SVN修订到Git标签?

[英]svn revision to Git tag?

I'm importing svn repository to Git (the tool will be Git Extensions). 我正在将svn存储库导入Git(该工具将是Git扩展)。 During the import process I'll see lines like: 在导入过程中,我将看到类似以下的行:

r155 = c154830e428e064e14c373d344f7b233c70c56a9 (refs/remotes/trunk) r155 = c154830e428e064e14c373d344f7b233c70c56a9(引用/远程/树干)

I'm guessing that this means in this case that svn revision 155 gets hash c15483... etc., am I correct? 我猜这意味着在这种情况下svn 155版会散列c15483 ...等等,对吗? In the future when we are living with Git and svn is "forgotten", it would be great that we could trace versions released before Git by svn revision numbers. 将来,当我们与Git一起生活并且svn被“遗忘”时,我们可以通过svn修订号来跟踪Git之前发布的版本,这将是很棒的。 So the question is, is there any way of importing svn revision number to Git commit tag during this import process (all revisions as tags would be great)? 所以问题是,在此导入过程中,是否有任何方法可以将svn修订版号导入到Git commit标签中(所有修订版都是很好的标签)? New commits will be handled differently, so this concerns only life before Git. 新提交的处理方式将有所不同,因此这仅涉及Git之前的生活。 I found a topic related to my case, but I'm not quite sure does is suit for me (actually the scripts in it): 我找到了一个与我的案子相关的主题,但我不太确定该主题是否适合我(实际上是其中的脚本):

git-svn: automatically importing/creating svn revisions as git tags git-svn:自动导入/创建svn版本作为git标签

From the mentioned line I'd like to have a tag 'r155' for example. 例如,在上面提到的行中,我想要一个标签“ r155”。 Because the environment is quite new, an example (for dummies) would be great... 因为环境很新,所以一个示例(用于虚拟对象)会很棒。

Thanks in advance! 提前致谢!

I found following: 我发现以下内容:

When converting from SVN to Git, how do I put the revision number in the commit message? 从SVN转换为Git时,如何将修订号放入提交消息中? (especially the one with sample script) (尤其是带有示例脚本的脚本)

The conversion is done pretty much like described in: 转换非常类似于以下内容中所述:

How to migrate SVN repository with history to a new Git repository? 如何将具有历史记录的SVN存储库迁移到新的Git存储库? (in the way described in most popular one) (以最受欢迎的一种描述)

And now the stupid(?) question: 现在是愚蠢的(?)问题:

How, where and at which point of the process I execute the script? 我如何,在何时何地执行脚本?

r155 = c154830e428e064e14c373d344f7b233c70c56a9 (refs/remotes/trunk) r155 = c154830e428e064e14c373d344f7b233c70c56a9(引用/远程/树干)

I'm guessing that this means in this case that svn revision 155 gets hash c15483... etc., am I correct? 我猜这意味着在这种情况下svn 155版会散列c15483 ...等等,对吗?

Yes, exactly. 对,就是这样。

In the future when we are living with Git and svn is "forgotten", it would be great that we could trace versions released before Git by svn revision numbers. 将来,当我们与Git一起生活并且svn被“遗忘”时,我们可以通过svn修订号来跟踪Git之前发布的版本,这将是很棒的。 So the question is, is there any way of importing svn revision number to Git commit tag during this import process (all revisions as tags would be great)? 所以问题是,在此导入过程中,是否有任何方法可以将svn修订版号导入到Git commit标签中(所有修订版都是很好的标签)?

Having a tag for every SVN revision does not seem like a good idea. 为每个SVN修订版添加标签似乎不是一个好主意。 Tags are meant for "special" revisions (typically those that were released in some way or put into production). 标签用于“特殊”修订(通常是通过某种方式发布或投入生产的修订)。 At any rate, git svn will by default embed the SVN revision into the commit message for every commit it creates. 无论如何,默认情况下git svn都会为它创建的每个提交将SVN修订版嵌入到提交消息中。

Example: 例:

Author: abc <abc@234986eef58-4435-45da-9345-24623feaa07>
Date:   Fri Apr 11 09:35:35 2014 +0000

    Fix bug #123.

    git-svn-id: http://svn/repo/url/trunk@4711 234986eef58-4435-45da-9345-24623feaa07

The git-svn-id contains the SVN revision after the "@" (4711 in this case). git-svn-id在“ @”之后包含SVN版本(在这种情况下为4711)。

Note that you can directly reference the git commit created from an SVN revision even without having a git tag for each one. 请注意,即使没有一个git标签,您也可以直接引用从SVN修订版创建的git commit。 Using the syntax :/text you can directly refer to a commit containing "text". 使用语法:/text您可以直接引用包含“ text”的提交。 So, to refer to the commit with SVN revision 123: 因此,要引用SVN修订版123的提交:

git show ":/@123 " git show“:/ @ 123”

Note the quotes and the trailing space; 注意引号和尾随空格; these are necessary to not match revisions that start with "123", like "1234". 对于不匹配以“ 123”开头的修订,例如“ 1234”,这些是必需的。

In summary: 综上所述:

You don't need to do anything special. 您不需要做任何特别的事情。 Just clone with git svn , and use the special syntax above if you need to refer to a commit by SVN revision. 只需使用git svn克隆,如果需要引用SVN修订版的提交,请使用上面的特殊语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM