1. 程式人生 > >fatal: remote origin already exists. (遠端來源已經存在 解決辦法)

fatal: remote origin already exists. (遠端來源已經存在 解決辦法)

在當我們輸入` git remote add origin https://gitee.com/(github/碼雲賬號)/(github/碼雲專案名).git `

就會報如下的錯

fatal: remote origin already exists.  

翻譯過來就是:致命:遠端來源已經存在

此時,我們可以先 git remote -v 檢視遠端庫資訊:

可以看到,本地庫已經關聯了origin的遠端庫,並且,該遠端庫指向GitHub。

解決辦法如下:

1、先輸入$ git remote rm origin(刪除關聯的origin的遠端庫)

2、再輸入$ git remote add origin

[email protected]:(github名)/(git專案名).git 就不會報錯了!

3、如果輸入$ git remote rm origin 還是報錯的話,error: Could not remove config section 'remote.origin'. 我們需要修改gitconfig檔案的內容

4、找到你的github的安裝路徑,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc

5、找到一個名為gitconfig的檔案,開啟它把裡面的[remote "origin"]那一行刪掉就好了!

 

記一次我關聯遠端庫遇到的錯誤

用了上面的辦法我就解決了(  希望能對看到的人有所幫助 )

推薦npm全域性安裝和本地安裝及解除安裝