Search code examples
gitsvngit-svn

Is it possible to make Git aware of SVN revisions?


When using git-svn, Git associates SVN revision with individual commits.

Most of other team members quote SVN revisions when they want their code reviewed. Is it possible to some how make Git 'aware' of the SVN revisions and implicitly convert them to Git hashes? Or perhaps is there a way to expose the mapping between Git commits and SVN revisions, so that I can write myself a tool that could leverage that?

Ideally I would like to do something like:

$ git diff r12000 e0a4f09 # r12000 is SVN revision, e0a4f09 is Git hash

Solution

  • The git-svn tool has a conversion option to find the git object if by a SVN revision, or the other way around. This option can be used as follows:

    git svn find-rev rSVNID
    

    Thus, your diff command could be:

    git diff $(git svn find-rev r12000) e0a4f09
    

    As opposed to the other answer, this should also work with branches and tags.

    For further information, see the manpage of git-svn on this command.