首页 > 解决方案 > 为什么我的 git repo 有两个别名?

问题描述

从我在其他问题上看到的情况来看,“来源”是您的存储库的别名,这样您就不必输入整个 url,对吗?如果是这样,为什么我还有另一个名为“github”的别名,两者都允许我获取和推送。有没有办法删除“github”?

me$ git remote -v
github  https://github.com/me/app.git (fetch)
github  https://github.com/me/app.git (push)
origin  https://github.com/me/app.git (fetch)
origin  https://github.com/me/app.git (push)

这里发生了什么?我试图删除“github”,但这不起作用。

git config --global --unset alias.github

标签: gitgithub

解决方案


那不是别名,而是远程。两者都是技术术语(行话):Git 别名是[alias]配置部分中的一个,您git config --global --unset将删除它,但远程是一个部分中的名称(因此可以保存多个设置 - 通常这里有两个,一个用于URL 和一个作为默认值)。[remote "name"]fetch

有没有办法删除“github”?

运行git remote remove github1


1您也可以使用git config删除整个部分,但与远程一起,您可能会有一些远程跟踪名称集,并且git remote remove会清理所有内容,而不仅仅是配置文件中的条目。


推荐阅读