2012-06-19 98 views
10

我可能失去了一些東西,但我敢肯定,我已經檢查過了,我 分叉回購並克隆它在我的系統上, 做了一些改動 commiting 做git push origin master的git github上不能推到原點

它說

fatal: remote error: 
    You can't push to git://github.com/my_username/my_repo.git 
    Use [email protected]:my_username/my_repo.git 

我缺少的東西? 然後我試圖 git remote add origin https://github.com/my_username/my_repo.git

它返回

致命:遠程起源已經存在。

我不明白這是爲什麼hapenning,請幫助

回答

21

git://github.com/my_username/my_repo.git 

混帳的網址://只給如方太提到只讀訪問..

enter image description here

然而,

[email protected]:my_username/my_repo.git 

給讀寫訪問,如網站

中所述

enter image description here

雖然,https://github.com/my_username/my_repo.git還具有讀取和寫入權限,但它不是在你的情況下工作,因爲你想創建具有相同名稱的新遠程復位,而不是它的。如提到的正確的語法是

git remote set-url origin [email protected]:my_username/my_repo.git

而且

git remote set-url origin https://github.com/my_username/my_repo.git 

也將工作。

+2

好的。謝謝,很好的解釋 – pahnin

4

git remote set-url origin [email protected]:my_username/my_repo.git

+0

工作,我會在時間限制後接受這個答案,bt你可以解釋我的問題是什麼?和許多thpk – pahnin

+0

我認爲https url只用於只讀存儲庫提取。但git @ github也提供了寫入和讀取權限。 –

+0

感謝您的信息:) – pahnin

0

之所以這樣不起作用是,git的://協議,你選擇了克隆,只配置在Github上讀取訪問權限(因爲它只支持匿名寫訪問而不受訪問限制)。
Github既支持ssh([email protected] ...),也支持https訪問存儲庫的寫入權限。

你的第二個命令失敗了,因爲當你克隆時,git已經創建了一個遠程命名的原點。所以如果你想添加另一個遠程倉庫,你必須提供另一個名字。

+0

thnks的解釋:) – pahnin