How to remove subversion remote in git?

主宰稳场 提交于 2019-12-20 09:26:21

问题


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?


回答1:


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.




回答2:


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




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/12013788/how-to-remove-subversion-remote-in-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!