ertza

software librea eta lokalizazioaren arteko ertzean.


Fixing git-svn after SourceForge update

Recently SourceForge has updated its SVN infrastructure and it seems that from now on git-svn dcommit doesn’t work anymore with repositories configured to use the plain HTTP protocol, so we have to change some things in order to have our git-svn environment working with HTTPS.

Wynand has shown me his orange-belt-git-man abilities and in a few minutes we’ve managed to get all the stuff working again. I’m going to list the command we’ve used just for the record.

  1. First, we create a file containing all our refs list, .git/packed-refs:
    $ git-gc
  2. Before making any change to our repository, we make a backup. After that, we can run git-filter-branch, a tool that lets rewrite the git revision history by rewriting the branches. Wynand provided a one-liner that does the job:
    $ git-filter-branch --msg-filter 'sed "s/git-svn-id: http/git-svn-id: https/g"' $(cat .git/packed-refs | awk '/[a-fA-F0-9]*/ {print $2}' | grep -v 'pack-refs')

    Which replaces the occurrences of http with https for each reference listed under .git/packed-refs. We should see something like this in the progress:

    Rewrite 05f17b2a31e82fc1354d3865ae9adcaef3a7ca5e (3374/3415)
  3. Then, we need to fix our repository configuration stored in .git/config:
    $ vi .git/config
    :s/http/https
    :wq
  4. Now, the first step to see whether it works:
    $ git-svn rebase

    Perhaps we get an error regarding SVN:

    Unable to determine upstream SVN information from working tree history

    In that case,

    rm -rf .git/svn/

    does the trick.

Note that probably we need to pass the -f flag to git-push the first time we’re pushing after this change.
Now we can keep on working with git and SVN! Thank you Wynand!