GitHub for Windows : how to unset svn-remote.svn.url

BaltoStar picture BaltoStar · Mar 6, 2013 · Viewed 7.5k times · Source

From cmd line at path for my local repo, I executed git svn clone command but with the wrong url.

I then tried to execute git svn clone with the correct url, but I can't because it tells me "svn-remote.svn.url already set"

How can I unset svn-remote.svn.url ?

Answer

me_and picture me_and · Mar 7, 2013

The error you're getting isn't massively helpful. svn-remote.svn.url refers to part of your Git configuration, which is stored in a couple of different files; this bit is in .git/config at the root of your repository.

There're a few different options for fixing this up:

  1. As others have suggested, just delete the entire Git repository and start again.

  2. Again, as Chronial suggested, delete the bit of the Git config that's duff. Two ways to do this:

    1. Use the git config command:

      git config --remove-section svn-remote.svn
      
    2. Editing the .git/config file yourself. If you open it up in a text editor, you'll find a bit that looks like this, which you'll want to delete:

      [svn-remote "svn"]
              url = http://duff.path/to/repo
              fetch = trunk:refs/remotes/svn/trunk
              branches = branches/*:refs/remotes/svn/*
              tags = tags/*:refs/remotes/svn/tags/*
      

    Since your URL was duff, you won't have any remote branches. If you had once made a successful git svn fetch/git svn clone, you'd need to worry about keeping the branches you had safe, or deleting them sensibly, but that's not a problem here.

    Either of the above steps will leave you as if you'd never run git svn clone, and you can start afresh.

  3. If the only thing wrong with your git svn clone command was the URL, you can just fix it up. As above, you can do this using git config:

    git config svn-remote.svn.url http://correct.path/to/repo
    

    or by editing .git/config by hand and correcting the paths.

    Once that's corrected, you can just run git svn fetch to finish the cloning.