Search code examples
gitsvngit-svn

How to repair git-svn history when the commit message of a svn commit changes?


I use git-svn to connect to a subversion server. It seems to be possible to change the subversion commit message (of an old commit). See the accepted answers here or here. However git svn rebase does not notice such change.

How can I tell git svn to "repair" such changes in its history?


At first I did not notice that my history was broken by still containing the old commit message until I added a remote. This remote is another git-svn checkout of the same server. When one of the two checkouts updates (using git svn rebase) before the commit message in svn is changed and the other updates after the change, then the git-svn branch will point to different SHA-1 hashes in my repository and the remotes repository. That is one of the git-svn branch pointer is wrong and needs to be resynchronized/repaired:

            / C  - D  - E  - F
.... - A - B
            \ C' - D' - E' - F'
              ^
         commit-message
         later changed

Solution

  • Use git svn reset -r <n> to reset (where <n> is a Subversion revision; see doc):

    reset

    Undoes the effects of fetch back to the specified revision. This allows you to re-fetch an SVN revision. [...] Follow reset with a fetch and then git reset or git rebase to move local branches onto the new tree.

    Example

    $ git svn find-rev B
    3
    $ git svn reset -r3
    r3 = 6f29012a3e25e00c899976b584084d6968aba43d (refs/remotes/git-svn)
    $ git svn fetch
    ...