1. 程式人生 > >git push遠端倉庫時報錯:fatal: remote origin already exists. (已解決)

git push遠端倉庫時報錯:fatal: remote origin already exists. (已解決)

 

 在做遠端倉庫除錯階段,突然發現修改後的專案無法push了:

 如果輸入$ git remote add origin [email protected]:djqiang(github帳號名)/gitdemo(專案名).git 

 提示出錯資訊:fatal: remote origin already exists.

 

檢查發現遠端倉庫由於專案的需要被手動重新命名了;

因此需要重新關聯下,

 

    解決辦法如下:

    1、先輸入$ git remote rm origin

    2、再輸入$ git remote add origin [email protected]:djqiang/gitdemo.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"]那一行刪掉就好了!