push代碼到code.google.com出錯問題解決

最近準備開源點代碼,就在code.goolge.com上申請了地方,使用git來管理代碼,結果第一次,不是很順暢。再加上對git也不熟,好好的折騰了一番。linux

下載代碼還好,直接照着作就能夠了。項目名就用project替代了,還沒弄好:)。git

git clone https://wangxuefu@code.google.com/p/project/

可是上傳的時候就出問題了,若有如下錯誤:
$ git push origin master:master
fatal: remote error: Invalid username/password.
You may need to use your generated googlecode.com password; see https://code.google.com/hosting/settings

用戶名和密碼出錯了,可是也沒有問我要用戶名和密碼啊?查了一下,原來是在git clone的時候,自動生成的連接中帶了用戶名,可是沒有帶密碼,因而認爲密碼爲空了,使用git remote -v看一下:shell

$ git remote -v
origin  https://username@code.google.com/p/project/ (fetch)
origin  https://username@code.google.com/p/project/ (push)

 若修改爲下面的方式,就會提示輸入用戶名和密碼了。 windows

$ git remote set-url --push origin https://code.google.com/p/project/
$ git remote -v
origin  https://username@code.google.com/p/project/ (fetch)
origin  https://code.google.com/p/project/ (push)

但每次輸入用戶名和密碼有很不方便,因此能夠讓他自動記住用戶名和密碼。在linux平臺上的方法,code.google上已經寫了,但windows上如何弄沒寫,有人是添加$HOME$/_netrc來解決的,可是還有更簡單的方法。先去https://code.google.com/hosting/settings上獲取到密碼,而後以下設置:fetch

$ git remote set-url --push origin https://username:password@code.google.com/p/project/
$ git remote -v
origin  https://username@code.google.com/p/project/ (fetch)
origin  https://username:password@code.google.com/p/project/ (push)

 而後再push代碼就不須要用戶名密碼了。google

相關文章
相關標籤/搜索