How to remove subversion remote in git?

GitGit Svn

Git Problem Overview


I have a git repository that was originally created using git-svn. Now I have a git server that I push to and the svn repository has been lost. Can I remove the svn remote? How?

Git Solutions


Solution 1 - Git

You can edit the .git/config file and remove the section associated with the remote you want to remove.

The lines you want to remove probably look roughly like this:

[svn-remote "svn"]
    url = url-of-svn-repository/trunk
    fetch = :refs/remotes/git-svn

This will remove the remote from Git, but you will still have the relationship between the Git commits and the SVN commits stored in .git/svn. You can remove this whole directory if you want to get rid of all your SVN remotes. If you want to get rid of just one SVN remote and keep others, you will need to look at the directory structure and only remove the ones associated with the remote you are removing.

Solution 2 - Git

Doing it via most *nix shells, bash or mingw32:

cd ~/your_repo
git config --remove-section svn

or whatever section you have when you view the config (cat .git/config). For example, the next line would remove the same config section described in Eric's solution:

git config --remove-section svn-remote.svn

next remove all svn stuff inside the .git folder (svn, logs, and refs). Which is also what Sergey suggests.

rm -rf .git/svn .git/{logs/,}refs/remotes/{git-,}svn/

garbage collection just for good measure:

git gc

source/credits

Solution 3 - Git

Eric's answer is correct, but not full. Even after Rafael Raposo's comment. I wish I could comment on the answer rather than posting a new one, but the rules are you can't comment until you reach 50 reputation.

The addition is:

find .git -type f -exec grep -nH git-svn "{}" \;

Showed me I had references in these two files:

./.git/info/refs:4:fd34a5c...8073f3 refs/remotes/git-svn
./.git/packed-refs:5:fd34a5...cd6c33 refs/remotes/git-svn

Until I removed those references, I could see git-svn doing git log

Solution 4 - Git

If you don't have any local config and you want to forego faffing about in the .git directory, simply clone the git repo from the git remote to a new directory and remove the old directory.

If you do have some simple local config (for example a different user/email to your global config), it's probably still easier to do this, and then restore any local config after cloning.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjlconlinView Question on Stackoverflow
Solution 1 - GitEricView Answer on Stackoverflow
Solution 2 - GitAnthony HatzopoulosView Answer on Stackoverflow
Solution 3 - GitSergey MarkelovView Answer on Stackoverflow
Solution 4 - GitjhabbottView Answer on Stackoverflow