git 如何在git中删除subversion remote?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12013788/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove subversion remote in git?
提问by jlconlin
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-svn 创建的 git 存储库。现在我有一个我推送到的 git 服务器并且 svn 存储库已经丢失。我可以删除 svn 遥控器吗?如何?
回答by Eric
You can edit the .git/config
file and remove the section associated with the remote you want to remove.
您可以编辑.git/config
文件并删除与要删除的遥控器相关联的部分。
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.
这将从 Git 中删除远程,但您仍将拥有存储在 .git 文件中的 Git 提交和 SVN 提交之间的关系.git/svn
。如果您想删除所有 SVN 遥控器,您可以删除整个目录。如果您只想删除一个 SVN 远程并保留其他人,您将需要查看目录结构并仅删除与您要删除的远程相关联的那些。
回答by Anthony Hatzopoulos
Doing it via most *nix shells, bash or mingw32:
通过大多数 *nix shell、bash 或 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:
或查看配置 ( cat .git/config
)时拥有的任何部分。例如,下一行将删除Eric 的解决方案中描述的相同配置部分:
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.
接下来删除.git
文件夹中的所有 svn 内容(svn、logs 和 refs)。这也是 Sergey 的建议。
rm -rf .git/svn .git/{logs/,}refs/remotes/{git-,}svn/
garbage collection just for good measure:
垃圾收集只是为了更好的衡量:
git gc
回答by Sergey Markelov
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.
埃里克的回答是正确的,但不完整。即使在 Rafael Raposo 发表评论之后。我希望我可以对答案发表评论而不是发布一个新的答案,但规则是您在达到 50 声望之前不能发表评论。
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-svndoing git log
在我删除这些引用之前,我可以看到git-svn正在做git log
回答by jhabbott
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.
如果你没有任何本地配置并且你想放弃在.git
目录中的胡说八道,只需将 git repo 从 git 远程克隆到一个新目录并删除旧目录。
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.
如果您确实有一些简单的本地配置(例如,与全局配置不同的用户/电子邮件),执行此操作可能更容易,然后在克隆后恢复任何本地配置。