git push提示Username for 'https://github.com' 解決辦法

因爲一些不當remote操作,根據github提示,最後git push提示Username for 'https://github.com'   

注意這裏的賬號是沒問題,可以password並不是賬號密碼的這個密碼,而是github裏面 develop setting 裏面的acess key;

$ git add .
$ git commit -m 'first commit'
[master (root-commit) 3f1b963] first commit
 1 files changed, 59 insertions(+)
 create mode 100644 readme.md
$ git remote add origin https://github.com/XXXX/project.git
$ git push -u origin master
Username for 'https://github.com':

網上搜索了一堆方案,最後實施繁雜而有各種因環境不同產生的問題;最終找到一個最直接有效的方法:

不用 HTTP 而是用 SSH 

change

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

to

[email protected]:XXXX/project.git

對應項目下運行

open -e .git/config

修改config裏面的對應值即可。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章