本人由于維護一些項目,經常需要提交代碼到github
服務器趁餐,當某些倉庫項目不屬于ssh
協(xié)議時,就會出現(xiàn)git push
要求輸入用戶名和密碼的情況篮绰,搜了一下給了個解決辦法后雷,這里記錄一下。
xs@xs-MacBookPro:~/test$ git push origin master
Username for 'https://github.com':
Linux下
- 在用戶跟目錄下
~/
創(chuàng)建文件.git-credentials
吠各,并打開編輯臀突,輸入內容:
https://{username}:{password}@github.com
#例如https://X-s:github110@github.com
在終端下執(zhí)行
git config --global credential.helper store
可以看到
~/.gitconfig
文件,會多了一項:
[credential]
helper = store
- 此時再去
push
則不用輸入賬戶名和密碼了
xs@xs-MacBookPro:~/test$ git push origin master
Everything up-to-date