When converting from SVN to Git, how do I put the revision number in the commit message?

喜欢而已 提交于 2019-12-03 16:50:57

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 tells git svn not to append the git-svn-id line.

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)

#!/bin/bash

declare -i rev

for ((rev = 1; rev < 100; ++rev))
do
    hash=$(git svn find-rev "r$rev")
    if [ -z $hash ]; then
        break
    fi
    # TODO Pad with 0's for small values of rev
    tag="svn_r$rev"
    git tag -a -m "$tag" $tag $hash
done

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.

Philip

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.

declare -i rev

for rev in {1..50000}
do
    echo $rev
    hash=$(git svn find-rev "r$rev")
    tag="svn_r$rev"
    if [ -z $hash ] 
    then
        echo no tag
    else
        echo $hash
        echo $tag
        git tag -a -m "$tag" $tag $hash
    fi
done

echo Thats it !
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!