I'm using Subgit to access a Subversion repo. It works great, but at times, especially when communicating with users who access the repo using an ordinary Subversion client, I'd really like to find to which SVN revision a particular changeset corresponds.
Can I, using git
find the SVN revision number somewhere in my local repo?
Yes, you can do that easily. You should just modify your
.git/config
file in the cloned Git repository to addoption and then run
git fetch
, as it is described in "Recommended client-side Git configuration" section of SubGit book. After thatgit log
command on the cloned repository will display revision numbers.If you want to do that on the server side (and if you don't use Git notes for other purposes in your project), you can run on the server machine
for one-time Git notes creation or you can run in that repository
to make refs/notes/commits follow refs/svn/map that is updated by SubGit and stores the latest revision <-> SHA-1 mapping. After that
git log
on the server will also display revision numbers.If you want to convert revisions to SHA-1 hashes in scripts (after setting up Git notes in any way mentioned above), you can use this command
in combination with line-parsing functions. E.g. if you don't care much about corner cases (e.g. branch name of name "r$REV branch"), to get SHA-1 and changed branch(es) name by revision REV you can run
Similarly you can grep SHA-1 or branch names here.