2016-09-06 47 views
0

我最近克隆了一個回購到我的本地驅動器,但現在我試圖推動所有更改到一個完整的新回購。然而,git一直告訴我,權限被拒絕,這是因爲它試圖推向最初克隆的回購。如何切換到新的遠程git存儲庫

詳情:

我最初從https://github.com/taylonr/intro-to-protractor克隆(即,基於一個Pluralsight當然在https://app.pluralsight.com/library/courses/protractor-introduction/table-of-contents)。

現在,我已經完成了課程,我想起來把我定型的代碼我自己的混帳回購協議(這只是我在GitHub上創建):

https://github.com/robertmazzo/intro-to-protractor

當我使用下面的git命令:

git的遠程添加原產https://github.com/robertmazzo/intro-to-protractor.git

它告訴我remote origin already exists,我想這很好,因爲我已經在github.com上創建了它。

但是,當我推進我的更改,我得到一個異常。

混帳推起源主

remote: Permission to taylonr/intro-to-protractor.git denied to robertmazzo. fatal: unable to access 'https://github.com/taylonr/intro-to-protractor.git/': The requested URL returned error: 403

所以我調查我如何可以切換到我的新的存儲庫,但是這也正是我的問題。我無法弄清楚這一部分。

+1

可能的複製[更改遠程Git倉庫的URI(URL)(HTTP ://stackoverflow.com/questions/2432764/change-the-uri-url-for-a-remote-git-repository) –

回答

0

需要添加新的遠程

git remote add <name> <url> 

,或者,如果你完全想刪除舊origin,先做

git remote remove origin 

然後

git remote add origin <url> 

注意消息remote origin already exists不好。它告訴你操作失敗,即它不能設置新的遠程。

0

在添加一個名爲「origin」的新遠程服務器之前,您需要刪除舊的遠程服務器,或者只是因爲某些原因需要訪問它時重命名該遠程服務器。

# Pick one 
git remote remove origin   # delete it, or ... 
git remote rename origin old-origin # ... rename it 

# Now you can add the new one 
git remote add origin https://github.com/robertmazzo/intro-to-protractor.git 
1

起源只是一個別名,以確定您的遠程倉庫。

您可以創建一個新的遠程引用,推動

git remote add new_origin https://github.com/robertmazzo/intro-to-protractor.git 
git push new_origin master 

如果要刪除以前的

git remote remove origin