简体   繁体   中英

svn revision to Git tag?

I'm importing svn repository to Git (the tool will be Git Extensions). During the import process I'll see lines like:

r155 = c154830e428e064e14c373d344f7b233c70c56a9 (refs/remotes/trunk)

I'm guessing that this means in this case that svn revision 155 gets hash c15483... etc., am I correct? 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. 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)? New commits will be handled differently, so this concerns only life before 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

From the mentioned line I'd like to have a tag 'r155' for example. 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? (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? (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)

I'm guessing that this means in this case that svn revision 155 gets hash c15483... etc., am I correct?

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. 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)?

Having a tag for every SVN revision does not seem like a good idea. 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.

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).

Note that you can directly reference the git commit created from an SVN revision even without having a git tag for each one. Using the syntax :/text you can directly refer to a commit containing "text". So, to refer to the commit with SVN revision 123:

git show ":/@123 "

Note the quotes and the trailing space; these are necessary to not match revisions that start with "123", like "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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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