2012-08-24 40 views
9

我跟着第一個步驟建立在github上的存儲庫後,但是當我到了行: git push -u origin master它失敗,此錯誤:Git的推返回錯誤,而不是提示輸入密碼

user$ git push -u origin master 
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/thestranger/cfinder.git/info/refs 

fatal: HTTP request failed 

我有遠程添加了正確的起源網址,我有git 1.7.10。奇怪的是,它並沒有提示我輸入用戶名或密碼,所以我不知道它試圖用什麼來訪問github上的倉庫。有誰知道爲什麼它不會提示我輸入密碼?

爲了澄清,我跟着步驟是的那些github上給我看後,立即在創建資源庫:

touch README.md 
git init 
git add README.md 
git commit -m "first commit" 
git remote add origin https://github.com/thestranger/cfinder.git 
git push -u origin master 
+0

哪個操作系統?你有安裝的SSH代理嗎? –

+0

Mac OS X,我認爲是。 – Swiss

+0

我在Mac OS X上也面臨同樣的問題 – AlienOnEarth

回答

10

您可以嘗試更改URL中使用SSH而不是HTTPS。在您的回購的根:

git remote set-url origin [email protected]:thestranger/cfinder.git 

這將要求您有一個公共密鑰註冊在您的GitHub帳戶。

+0

謝謝,這工作,我仍然想知道問題是什麼。 – Swiss

+1

我也不確定。我一直使用HTTPS進行只讀訪問和SSH進行讀寫。 – Brandan

3

HTTPS應予以支持,但你需要的Git 1.7.10+

0

git 1.7.1,一個可以遠離改變:

https://github.com/username/project.git 

https://[email protected]/username/project.git 

這樣一來,它肯定會提示輸入密碼。