Grab the svn HEAD git commit number?

In regular git I can run

git rev-parse HEAD

to get the git HEAD revision number. How would I get the svn HEAD revision number instead?

  • What does it mean when Git diff shows mode changes?
  • How to change the starting point of a branch?
  • invalid author/committer line - missing space before email
  • Getting Clear read only status on Webstorm 8
  • Git Extensions usable with SVN repos?
  • How to work around updating polymer-cli on Ubuntu on Windows which fails due to .git: Permission denied
  • I know I can manually grab it by looking at the git log for the last commit with a git-svn-id.
    Also, looking through the manual for log pretty-format there’s a way to get the ref name (%d) which in the case of the HEAD svn commit shows up as git-svn.


  • Apply github commit / pull request as a patch
  • Cloning SVN repository for Git
  • Problems with Python indentations when cloning from GitHub
  • TeamCity triggers too many builds for a new branch
  • Git couldn't resolve proxy
  • Git - Create a new remote branch out of an old commit
  • 2 Solutions collect form web for “Grab the svn HEAD git commit number?”

    It’s a bit of a hack and I welcome improvements but here’s what I’ve got so far.

    I’ve added an alias to my git config:

    svnhead = log --grep=git-svn --pretty=format:'%h' -n 1

    now I can call

    git svnhead 

    to return the short git commit hash and I can pass it in to

    git rebase -i $(git svnhead)

    for example to interactive rebase everything from the svn head commit.

    EDITED 9/23/13

    I recently realized this can be done using rev-parse:

    git rev-parse master

    if your master branch tracks the SVN repo, or

    git rev-parse git-svn 

    git svn find-rev HEAD will give you the SVN revision number

    git svn find-rev r$(git svn find-rev HEAD) will give you the git commit hash for that revision.

    Git Baby is a git and github fan, let's start git clone.