我试图按照迈克尔哈特尔的Rails教程,但我遇到了一个错误。
我在GitHub注册了,发放了一个新的SSH密钥,并创建了一个新的存储库。但是当我在终端中输入下一行时,我得到了以下错误:
Parkers-MacBook-Pro:.ssh ppreyer$ git remote add origin git@github.com:ppreyer/first_app.git
fatal: remote origin already exists.
只是想知道是否有人遇到过这个问题?
我试图按照迈克尔哈特尔的Rails教程,但我遇到了一个错误。
我在GitHub注册了,发放了一个新的SSH密钥,并创建了一个新的存储库。但是当我在终端中输入下一行时,我得到了以下错误:
Parkers-MacBook-Pro:.ssh ppreyer$ git remote add origin git@github.com:ppreyer/first_app.git
fatal: remote origin already exists.
只是想知道是否有人遇到过这个问题?
当前回答
如果你需要检查你已经连接到本地回购的远程回购,有一个cmd:
git remote -v
现在,如果你想删除远程回购(比如,origin),那么你可以做的是:
git remote rm origin
其他回答
如果你需要检查你已经连接到本地回购的远程回购,有一个cmd:
git remote -v
现在,如果你想删除远程回购(比如,origin),那么你可以做的是:
git remote rm origin
$ git remote add origin git@gitlab.com:abc/backend/abc.git In this command origin is not part of command it is just name of your remote repository. You can use any name you want. First You can check that what it contains using below command $ git remote -v It will gives you result like this origin git@gitlab.com:abc/backend/abc.git (fetch) origin git@gitlab.com:abc/backend/abc.git (push) origin1 git@gitlab.com:abc/backend/abc.git (fetch) origin1 git@gitlab.com:abc/backend/abc.git (push) if it contains your remote repository path then you can directly push to that without adding origin again If it is not contaning your remote repository path Then you can add new origin with different name and use that to push like $ git remote add origin101 git@gitlab.com:abc/backend/abc.git Or you can rename existing origin name add your origin git remote rename origin destination fire below command again $ git remote -v destination git@gitlab.com:abc/backend/abc.git (fetch) destination git@gitlab.com:abc/backend/abc.git (push) It will change your existing repos name so you can use that origin name Or you can just remove your existing origin and add your origin git remote rm destination
首先做一个:
git remote rm origin
然后
git remote add origin https://github.com/your_user/your_app.git
瞧!为我工作!
短版:
您只需更新现有的远程:
$ git remote set-url origin git@github.com:ppreyer/first_app.git
长版:
正如错误消息所示,已经有一个配置了相同名称的远程服务器。因此,您可以使用不同的名称添加新的远程设备,如果不需要的话,也可以更新现有的远程设备。
要添加一个新的远程,例如,调用github而不是origin(显然已经存在于您的系统中),执行以下操作:
$ git remote add github git@github.com:ppreyer/first_app.git
记住,尽管在教程中你看到“起源”,你应该把它换成“github”。例如$ git push origin master现在应该是$ git push github master。
但是,如果你想查看已经存在的原始远程是什么,你可以执行$ git remote -v。如果你认为这是由于一些错误,你可以这样更新它:
$ git remote set-url origin git@github.com:ppreyer/first_app.git
如果你想通过GUI做以下事情:
确保“隐藏文件”在项目文件夹中可见 进入“。git”目录 编辑config.txt文件中的url文件并保存该文件!